Is there a way to get this code to only select across a certain number of columns as this code seems to be selecting everything on the sheet.
Of course. I misread your original post. Sorry about that:
Sub Select_Range()
Dim ws As Worksheet: Set ws = Sheets("Sheet1")
Dim iCol As Integer, myCol As Integer, numVisible As Integer
myCol = 0
numVisible = 0
For iCol = 1 To ws.UsedRange.Columns.Count
If ws.Cells(1, iCol).EntireColumn.Hidden = False Then
numVisible = numVisible + 1
End If
If numVisible = 3 Then
myCol = iCol
Exit For
End If
Next iCol
ws.Range(ws.Cells(1, 1), ws.Cells(ws.UsedRange.Rows.Count, myCol)).SpecialCells(xlCellTypeVisible).Select
End Sub
Bookmarks