I have the following code:
Sub test()
Dim r As Range, rng As Range
Set r = Range("a6", Range("a6").End(xlDown))
For Each rng In r
If rng <> rng.Offset(-1) Then 'if range is not
Dim ws As Worksheet
Set ws = Worksheets.Add
ws.Name = rng
Else
End If
Next rng
End Sub
This will go through the range from A6 to AXX and create worksheets for different names. I somehow cannot figure out how to copy the contents of each row into each worksheet created.
So, I want all Ticker changes to be copied to the new ticker of the added worksheet.
I know there is a way:
Range(Cells(rng, 1), Cells(rng, 10)).Copy
But I do not know how to insert them into another worksheet. Can anyone ask for advice or guidance. thanks
Also, when I try to run this macro, it sometimes says:
This name is already accepted, try another.
However, there is no worksheet with this name.
source
share