?
Solved

VB Code

Posted on 2011-02-21
4
Medium Priority
?
230 Views
Last Modified: 2012-05-11
Please can you help, I would like a command button that can find the last value within Column B (B14 downwards)

So if there was text in B14,15,16,17 the command button would select B18

If there was no text in any of the columns from B14 down... then B14 would be selected
0
Comment
Question by:Gazza83
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 33

Accepted Solution

by:
jppinto earned 2000 total points
ID: 34947440
Attached you can find an working example with the code below.

jppinto
Sub find_last()
Dim lstRow As Long
   lstRow = Sheets("Sheet1").Cells(ActiveSheet.Rows.Count, "B").End(xlUp).Row
   ActiveSheet.Cells(lstRow, 2).Select
End Sub

Open in new window

FindLastRow.xlsm
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 34947671
Hi there, try this.

Regards,

Rob.
intNextRow = GetNextRow("B")

Sub GetNextRow(strColumn As String)
	intRow = ActiveSheet.Cells(65536, strColumn).End(xlUp).Row
	If intRow < 14 Then
		intRow = 14
	Else
		intRow = intRow + 1
	End If
	GetNextRow = intRow
End Sub

Open in new window

0
 
LVL 65

Expert Comment

by:RobSampson
ID: 34947676
Yikes, didn't refresh for almost an hour...
0
 
LVL 33

Expert Comment

by:jppinto
ID: 34947701
LOL...it happens to all sometimes.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question