View Full Version : [SOLVED:] How to print from sheet active to the another sheet
Nader
02-13-2011, 04:02 AM
I tried this code to print the data in any sheets active or select(unless sheet2) to the sheet2. but didn't work.
Dim wsh As Worksheet
For Each wsh.Select In Worksheets
Sheets(2).Range("H1").Value = wsh.Range("K1").Value
Next
Bob Phillips
02-13-2011, 06:36 AM
Dim wsh As Worksheet
For Each wsh In Worksheets
If Not wsh Is Worksheets("Sheet2") Then
Worksheets("Sheet2").Range("H1").Value = wsh.Range("K1").Value
End If
Next wsh
Nader
02-13-2011, 07:05 AM
it works only for one sheet. I have 4 sheets this code apply only for sheet4
mdmackillop
02-13-2011, 09:33 AM
Your code is overwriting the previous data. You may need something like
Dim wsh As Worksheet, i as Long
For Each wsh In Worksheets
If Not wsh Is Worksheets("Sheet2") Then
Worksheets("Sheet2").Range("H1").Offset(i).Value = wsh.Range("K1").Value
i = i + 1
End If
Next wsh
Nader
02-13-2011, 12:35 PM
your code but when I excute it on the sheet1 example it print the data to H1 on sheet2 and then when i excute it on the sheet3 it print in H2 not in H1.. and so
I tried this coed and it works
Sheets(2).Range("H1").Value = Activesheet.Range("K1").Value
thank's all for help!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.