How do I Advancing to next column/cell in a Sheet.range(x)?

  • Thread starter Thread starter RandyR
  • Start date Start date
R

RandyR

I have the following Macro and it works well untill I try to rename the
2nd sheet. I need to advance to the next Column (Example: B1 , C1, D1
....) in my Sheet(2).Range("X"). Is there anyway to do this? If so,
How?

Thanks,
Randy


Sub Macro 1
'
Dim nFloors
Dim nCount
Dim i
Dim nSheet

nCount = Sheets(1).Range("B26")
For i = 1 To nCount
nSheet = Application.Sheets.Count

If i = nFloors Then
End
End If
Application.ScreenUpdating = False

Sheets(3).Copy After:=Sheets(nSheet)
ActiveSheet.Name = "Floor " & Sheets(2).Range("B1")

Next i
End Sub
 
With your current code the easiest would be to use i as your offset something
like this...

ActiveSheet.Name = "Floor " & Sheets(2).Range("B1").offset(0, i-1).value

As a complete aside you should be declaring your variable types. All of your
variables are of type variant which is very inefficient. If you are unsure
what I mean check out this site...

http://www.cpearson.com/excel/variables.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top