DataBlake
Well-known Member
- Joined
- Jan 26, 2015
- Messages
- 781
- Office Version
- 2016
- Platform
- Windows
I want to store lastCol as a variable equal to the last column in the current selection
but with this code the range of the selection doesnt seem to be doing anything. it just counts the entirety of the worksheet's columns.
where if i have data from a1:m7 and i select d1:h5 the lastCol value should be 5 and the row be 5.
what do?
Code:
Sub selectionEDIT()
Dim sSelect As Range
Dim lastCol As Long
Dim lastRow As Long
Set sSelect = Selection
lastCol = sSelect.SpecialCells(xlCellTypeLastCell).Column
lastRow = sSelect.SpecialCells(xlCellTypeLastCell).Row
but with this code the range of the selection doesnt seem to be doing anything. it just counts the entirety of the worksheet's columns.
where if i have data from a1:m7 and i select d1:h5 the lastCol value should be 5 and the row be 5.
what do?