I am trying to concatenate a string with the activesheet name to name a range (cell). This cells value from each individual sheet will then be copied to a summary sheet.
So if salesperson Joe has commissions on sheets Branch1, Branch2 and Branch3, the cell names for Joe’s commissions on these sheets will be JoeBranch1, JoeBranch2 and JoeBranch3, respectively.
I get an error message “That name is not valid” when the first concatenation should happen.
TIA,
Bill
So if salesperson Joe has commissions on sheets Branch1, Branch2 and Branch3, the cell names for Joe’s commissions on these sheets will be JoeBranch1, JoeBranch2 and JoeBranch3, respectively.
I get an error message “That name is not valid” when the first concatenation should happen.
Code:
Sub NamingCommissionCellsForCopyingToSummarySheet()
Application.ScreenUpdating = False
Dim Wsheet As String
Wsheet = ActiveSheet.Name '<<this works
'For Each sheet In ActiveWorkbook.Worksheets
Range("A2").Select 'have to start at col A or Loop will not work
Do
With ActiveCell
If ActiveCell.Font.Bold = True Then
If Left(ActiveCell, 2) = 1 Then _
ActiveCell.Offset(0, 11).Name = "Joe" & Wsheet ‘<<Error here
If Left(ActiveCell, 2) = 2 Then _
ActiveCell.Offset(0, 11).Name = "HouseAccount"
If Left(ActiveCell, 2) = 9 Then _
ActiveCell.Offset(0, 11).Name = "HouseAccount"
If Left(ActiveCell, 2) = 18 Then _
ActiveCell.Offset(0, 11).Name = "JoeThomaCommissions"
End If
End With
With ActiveCell 'need to fix this
.Offset(1, 0).Select 'gotta have this or will get caught in loop
End With
'Stop
Loop Until ActiveCell = "Grand Total" 'Or _
ActiveCell = "Pay This Amount>>"
'Stop
'Next sheet
Range("A1").Select
Application.ScreenUpdating = True
End Sub
TIA,
Bill