Excel vba how to select last row

lecet444

Board Regular
Joined
May 18, 2011
Messages
91
HOW TO SELECT LAST ROW, MORE IMPORTANTLY A CELL IN THAT LAST ROW WITH DATA

Code:
    Dim i As Integer
    For i = 2 To 10000
 
 TextBox4.Value = Range("B2").Value
 textbox5.value = (I WANT THAT TO BE LAST CELL IN THE B COLUMN)

I DUNNO WHERE TO GO FROM THERE
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Try:

Code:
    Dim i As Integer
    For i = 2 To 10000
 
TextBox4.Value = Range("B2").Value
textbox5.value = [COLOR=red][B]Range("B" & Rows.Count).End(xlUp).Value[/B][/COLOR]
 
Upvote 0
actually i made a mistake, the second part of your code works good
my first part. I was selecting a cell in a filter. I want to select the cell b that comes right after b1(down). its always changing relative to the filter I apply
 
Upvote 0
actually i made a mistake, the second part of your code works good
my first part. I was selecting a cell in a filter. I want to select the cell b that comes right after b1(down). its always changing relative to the filter I apply

Try this out:
Code:
    Dim i As Long
    Dim LR  As Long
    LR = Range("B" & Rows.Count).End(xlUp).Row
    For i = 2 To 10000
 
TextBox4.Value = Range("B2:B" & LR).SpecialCells(xlCellTypeVisible).Cells(1).Value
textbox5.Value = LR
 
Upvote 0
Try this out:
Code:
    Dim i As Long
    Dim LR  As Long
    LR = Range("B" & Rows.Count).End(xlUp).Row
    For i = 2 To 10000
 
TextBox4.Value = Range("B2:B" & LR).SpecialCells(xlCellTypeVisible).Cells(1).Value
textbox5.Value = LR

Thank You ver much I tweaked the last bit though, to give me the cell value

Code:
    Dim i As Long
    Dim LR  As Long
    LR = Range("B" & Rows.Count).End(xlUp).Row
    For i = 2 To 10000
 
TextBox4.Value = Range("B2:B" & LR).SpecialCells(xlCellTypeVisible).Cells(1).Value
textbox5.Value = range [COLOR=red]("B" & LR[/COLOR])

Much appreciated
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,828
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top