VBABEGINER
Well-known Member
- Joined
- Jun 15, 2011
- Messages
- 1,284
- Office Version
- 365
- Platform
- Windows
I need "Last used column" in code. Example, last column used is AI, so AI column number in i variable
Sub Lastcolum_Me()
Dim Lastcolumn As Long
Lastcolumn = Cells(1, Columns.Count).End(xlToLeft).Column
MsgBox Lastcolumn
End Sub
Dim i As Long
i = Range("A1").SpecialCells(xlLastCell).Column
Option Explicit
[COLOR=navy]Dim[/COLOR] Rng [COLOR=navy]As[/COLOR] Range
Private [COLOR=navy]Sub[/COLOR] Worksheet_SelectionChange(ByVal Target [COLOR=navy]As[/COLOR] Range)
[COLOR=navy]Dim[/COLOR] i [COLOR=navy]As[/COLOR] [COLOR=navy]Long[/COLOR]
[COLOR=navy]If[/COLOR] Rng [COLOR=navy]Is[/COLOR] Nothing [COLOR=navy]Then[/COLOR]
[COLOR=navy]Set[/COLOR] Rng = Target
[COLOR=navy]Else[/COLOR]
i = Rng.Column
MsgBox i
[COLOR=navy]Set[/COLOR] Rng = Target
[COLOR=navy]End[/COLOR] If
[COLOR=navy]End[/COLOR] [COLOR=navy]Sub[/COLOR]
Sub LastUsedColumn()
' hiker95, 04/19/2018, ME1052368
Dim lastcolumn As Long
lastcolumn = Cells.Find("*", , xlValues, xlWhole, xlByColumns, xlPrevious, False).Column
End Sub
Sub fnCombine()
Dim n As Integer
'To always select 1st sheet
n = ActiveWorkbook.Worksheets.Count
ActiveWorkbook.Worksheets("Atlantic").Select
i = Range("A1:A5000").Find("Monthly", Range("A1"), xlValues, xlWhole, xlByColumns, xlNext).Row
LC = Cells(3, Columns.Count).End(xlToLeft).Column
Range(Cells(i + 4, 1), Cells(?, LC)).Select
'? = last employee row
End Sub
bLR = Range("B5").End(xlDown).Count
can i please get help on this..
it giving me row number i.e. 13. I dont want that 13..I want count..So i will understand here only how employee names are there..Code:bLR = Range("B5").End(xlDown).Count