Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

excel problem/VB

Status
Not open for further replies.

stalker3

Technical User
Mar 11, 2004
1
0
0
US
I have a problem with understanding VB. I have a worksheet(1) in Excel inwhich there is a field of numbers. I want to place a checkbox next to each number. When the checkbox is checked, I want to copy an area (A1:C5) from another worksheet(2) (same workbook) and place it on another worksheet(3)to be printed. If anyone can make sense out of this and get me going in the right direction, I would be very thankful.
 
I am not sure about the check box in your second column...
but here is the code.


applfile = "c:\your_excel_filename.xls"
Workbooks.Open applfile
Set datasheet1 = Worksheets("worksheet1")
set datasheet2 = Worksheets("worksheet2")
set datasheet3 = Worksheets("worksheet3")
'get the starting row and the last row from sheet1

for x = startrow to endrow
if datasheet1.cells(x,column) = checked then
datasheet2.range("a1:c5").select
selection.copy
datasheet3.cells(x,column).select
activesheet.paste
end if
next

open the excel sheet go to record macro from tools and start the macro1,
select a range of cells from sheet1 and press ctrl c, select sheet2 and press ctrl v
stop the macro, again select the macro from tools edit the macro1 you get the code.....

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top