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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
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,560
Messages
6,120,217
Members
448,951
Latest member
jennlynn

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