Solved

VB Code

Posted on 2011-02-21
4
222 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
Comment Utility
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
Comment Utility
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
Comment Utility
Yikes, didn't refresh for almost an hour...
0
 
LVL 33

Expert Comment

by:jppinto
Comment Utility
LOL...it happens to all sometimes.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
using web browser with BING 40 83
Excel 2013 Problem 12 44
How to batch remove spreadsheet password 19 83
Sending Attachment via CDO 3 10
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now