HELP ! - Macro code to copy sheet name X number of times bas

Cosmos75

Active Member
Joined
Feb 28, 2002
Messages
359
I need help with fine-tuning my macro. I have a macro that looks for lists on several worksheets that vary in length and I have that part done. I want to add next to those lists the names of the sheets they came from. Here's that part of the code that I cant get to work.


For Each ws In Worksheets
If ws.Name <> "Summary" Then
If ws.Name <> "Conversion Factors" Then
If ws.Name <> "HI" Then

upperconstituent = ws.Range("B65536").End(xlUp).End(xlUp).Offset(1, 0).Address
lowerconstituent = ws.Range("B65536").End(xlUp).Address

ws.Select
ws.Range(upperconstituent, lowerconstituent).Select
RowCounter = Selection.Count
For i = 1 To RowCounter
Sheets("HI").Select
Range("A65536").End(xlUp).Select
CoatingCounter = Selection.Count
Range(Range("A65536").End(xlUp).Address, Range("A", CoatingCounter + i)).Value = ws.Name
Next i

End If
End If
End If


Next ws

I need help with thhis part of the code

Range("A", CoatingCounter + i)).

I get an error message "Method 'Range' of Object '_Global' Failed"
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Fixed it!

Dim RowCounter As Integer
Dim CoatingCounter As Integer

'Insert Coating Name
ws.Select
ws.Range(upperconstituent, lowerconstituent).Select
RowCounter = Selection.Count
Sheets("HI").Select
Range(Range("A65536").End(xlUp).Offset(1, 0).Address, Range("A65536").End(xlUp).Offset(RowCounter, 0).Address).Value = ws.Name
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,497
Members
448,967
Latest member
visheshkotha

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