DIM

Andy D 2002

Board Regular
Joined
Apr 22, 2002
Messages
106
hi i'm a bit of a novice, how do i change below so copies to, say, "sheet2" instead of adding new sheet
thanks
Andy


Dim v
Dim s As Range
Dim c As Range
Dim t As Range
Dim sTitle As Range
Dim w As Worksheet
Set s = ActiveSheet.Range("i2")
Set s = ActiveSheet.Range(s.End(xlToRight), s.End(xlDown))
Set sTitle = ActiveSheet.Range("A1:H1")
Set w = Worksheets.Add()
Set t = w.Range("A1")
sTitle.Range("A1:H1").Copy
t.Range("A1:H1").PasteSpecial xlPasteValues
For Each c In s
Set t = t.Offset(1, 0)
c.End(xlToLeft).Range("A1:H1").Copy
t.Range("A1:H1").PasteSpecial xlPasteValues
t.Offset(0, :cool: = c.End(xlUp).Value
t.Offset(0, 9) = c.Value
Next
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
I'm assuming that "Sheet2" is the name of the sheet on the worksheet tab.

Dim v
Dim s As Range
Dim c As Range
Dim t As Range
Dim sTitle As Range
Dim w As Worksheet
Set s = ActiveSheet.Range("i2")
Set s = ActiveSheet.Range(s.End(xlToRight), s.End(xlDown))
Set sTitle = ActiveSheet.Range("A1:H1")
' Set w = Worksheets.Add()
' Set t = w.Range("A1")
sTitle.Range("A1:H1").Copy
Sheets("Sheet2").Range("A1:H1").PasteSpecial xlPasteValues
For Each c In s
Set t = Sheets("Sheet2").Offset(1, 0)
c.End(xlToLeft).Range("A1:H1").Copy
t.Range("A1:H1").PasteSpecial xlPasteValues
t.Offset(0, 8)= c.End(xlUp).Value
t.Offset(0, 9) = c.Value
Next

I think that will work.
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,716
Members
448,985
Latest member
chocbudda

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top