Solved

VB Code

Posted on 2011-02-21
4
225 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
  • 2
  • 2
4 Comments
 
LVL 33

Accepted Solution

by:
jppinto earned 500 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

777 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