I need to be able to count how many columns that have data in them from a given column. Example: I have a sheet that has A thru AX that will always have data. Now based upon what is on the data sheet I am always coping A - AX but I could have AY thru RZ columns with data or no addtional data columns. I have this code which works for 1 to 100 additional colums but does not work for NO additional columns.
wsSource.Activate
wsSource.Range("AX10:" & wsSource.Range("AW9").End(xlToRight).Offset _
(wsSource.UsedRange.Rows.Count - 8, 0).Address).Select
intStores = Selection.Columns.Count
wsTarget.Range("AW13").Formula = "=(" & intStores & "-AX13)*FA13"
Application.Calculate
If (intStores = 1) Then
boolOneStore = True
' ElseIf (intStores > 2) Then Stop - NOTE SETTINGS: intStores originally set to 9 - remains @9
ElseIf (intStores > 2) Then
wsTarget.Range("AY13: " & wsTarget.Range("AY13").Offset(0, intStores - 3).Address).EntireColumn.Insert
Worksheets("Summary").Range("O35:" & Worksheets("Summary").Range("O35").Offset(0, intStores - 3).Address).EntireColumn.Insert
End If
wsSource.Activate
wsSource.Range("AX10:" & wsSource.Range("AW9").End(xlToRight).Offset _
(wsSource.UsedRange.Rows.Count - 8, 0).Address).Select
intStores = Selection.Columns.Count
wsTarget.Range("AW13").Formula = "=(" & intStores & "-AX13)*FA13"
Application.Calculate
If (intStores = 1) Then
boolOneStore = True
' ElseIf (intStores > 2) Then Stop - NOTE SETTINGS: intStores originally set to 9 - remains @9
ElseIf (intStores > 2) Then
wsTarget.Range("AY13: " & wsTarget.Range("AY13").Offset(0, intStores - 3).Address).EntireColumn.Insert
Worksheets("Summary").Range("O35:" & Worksheets("Summary").Range("O35").Offset(0, intStores - 3).Address).EntireColumn.Insert
End If