Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Select a cell

Can someone give me the correct syntax to select the last cell in
column A which contains the word "BATCH" ?


Sub Find_Last()
Sheets("TEST").Select
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
For x = lastrow To 1 Step -1
If InStr(1, (Cells(x, 1).Value), "BATCH") 0 Then
Range("A" & x, 1).Select
Exit For
End If
Next x
End Sub


I think everything is correct except the Range statement. What should I
replace it with to place my cursor in the last cell that contains the
word "BATCH"?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Select a cell

give this a try

Option Explicit
Dim x As Long
Dim lastrow As Long
Sub Find_Last()
With Sheets("TEST")
lastrow = .Cells(Rows.Count, "A").End(xlUp).Row
For x = lastrow To 1 Step -1
If InStr(1, (.Cells(x, 1).Value), "BATCH") Then
Range("A" & x).Select
Exit For
End If
Next x
End With
End Sub


--


Gary


"slowjam4" wrote in message
oups.com...
Can someone give me the correct syntax to select the last cell in
column A which contains the word "BATCH" ?


Sub Find_Last()
Sheets("TEST").Select
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
For x = lastrow To 1 Step -1
If InStr(1, (Cells(x, 1).Value), "BATCH") 0 Then
Range("A" & x, 1).Select
Exit For
End If
Next x
End Sub


I think everything is correct except the Range statement. What should I
replace it with to place my cursor in the last cell that contains the
word "BATCH"?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Select a cell

one thing i forgot to mention, this will find BATCH, not "Batch" or any other
variant.

--


Gary


"slowjam4" wrote in message
oups.com...
Can someone give me the correct syntax to select the last cell in
column A which contains the word "BATCH" ?


Sub Find_Last()
Sheets("TEST").Select
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
For x = lastrow To 1 Step -1
If InStr(1, (Cells(x, 1).Value), "BATCH") 0 Then
Range("A" & x, 1).Select
Exit For
End If
Next x
End Sub


I think everything is correct except the Range statement. What should I
replace it with to place my cursor in the last cell that contains the
word "BATCH"?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Select a cell

Thanks Gary. Your solution worked like a charm.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA: Column Select then Data Select then return to cell A1 James C[_2_] Excel Discussion (Misc queries) 3 February 1st 10 11:35 AM
Using formulas to select cells (Ex: Select every nth cell in a col Lakeview Photographic Services Excel Discussion (Misc queries) 2 March 15th 07 02:17 PM
How to point to (select) a cell to the left from a cell where I enter the = equal sign? Dmitry Excel Discussion (Misc queries) 4 June 30th 06 06:49 AM
I cannot select a single cell or pull down cell contents Carolyn Fahm Excel Worksheet Functions 0 January 24th 06 04:54 PM
Select cell, Copy it, Paste it, Return to Previous cell spydor Excel Discussion (Misc queries) 1 December 30th 05 01:29 PM


All times are GMT +1. The time now is 06:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"