Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
RAP RAP is offline
external usenet poster
 
Posts: 49
Default Select row from macro

What a wonderful forum. I have received excellent advice regarding another
issue, which has saved me tons of time. Thanks to all. So, may I have
another?....

I have a date on page 1 (cell D2) and a column of dates on page 2, in
sequential order, in column A. Each date has a row of information next to
it, typically 8 to 10 cells worth.

I am looking for a way, using a macro, to select the entire row of a
certain date on page 2 that matches the date on page 1 (which is
selectable).

Thank you,
Randy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Select row from macro

Hi Randy,

One way:

'===========================
Sub Tester()
Dim rng As Range
Dim searchStr As Long
Dim sh1 As Worksheet
Dim sh2 As Worksheet
Dim irow As Long

Set sh1 = ThisWorkbook.Sheets(1)
Set sh2 = ThisWorkbook.Sheets(2)

searchStr = sh1.Range("D2").Value

If Not IsError(Application. _
Match(searchStr, sh2.Columns(1).Cells, 0)) Then
irow = Application.Match _
(searchStr, sh2.UsedRange.Columns(1), 0)
Set rng = Intersect(sh2.Rows(irow), sh2.UsedRange)
Else
MsgBox Format(searchStr, "MM/DD/YY") _
& " not found on " & sh2.Name
End If

If Not rng Is Nothing Then Application.Goto rng

End Sub
'<<===========================


---
Regards,
Norman



"RAP" wrote in message
...
What a wonderful forum. I have received excellent advice regarding
another
issue, which has saved me tons of time. Thanks to all. So, may I have
another?....

I have a date on page 1 (cell D2) and a column of dates on page 2, in
sequential order, in column A. Each date has a row of information next to
it, typically 8 to 10 cells worth.

I am looking for a way, using a macro, to select the entire row of a
certain date on page 2 that matches the date on page 1 (which is
selectable).

Thank you,
Randy



  #3   Report Post  
Posted to microsoft.public.excel.programming
RAP RAP is offline
external usenet poster
 
Posts: 49
Default Select row from macro

Norman,

Vunderbar!! It worked beautifully! Thank you very much. I never would
have come up with that.
Randy

"Norman Jones" wrote:

Hi Randy,

One way:

'===========================
Sub Tester()
Dim rng As Range
Dim searchStr As Long
Dim sh1 As Worksheet
Dim sh2 As Worksheet
Dim irow As Long

Set sh1 = ThisWorkbook.Sheets(1)
Set sh2 = ThisWorkbook.Sheets(2)

searchStr = sh1.Range("D2").Value

If Not IsError(Application. _
Match(searchStr, sh2.Columns(1).Cells, 0)) Then
irow = Application.Match _
(searchStr, sh2.UsedRange.Columns(1), 0)
Set rng = Intersect(sh2.Rows(irow), sh2.UsedRange)
Else
MsgBox Format(searchStr, "MM/DD/YY") _
& " not found on " & sh2.Name
End If

If Not rng Is Nothing Then Application.Goto rng

End Sub
'<<===========================


---
Regards,
Norman



"RAP" wrote in message
...
What a wonderful forum. I have received excellent advice regarding
another
issue, which has saved me tons of time. Thanks to all. So, may I have
another?....

I have a date on page 1 (cell D2) and a column of dates on page 2, in
sequential order, in column A. Each date has a row of information next to
it, typically 8 to 10 cells worth.

I am looking for a way, using a macro, to select the entire row of a
certain date on page 2 that matches the date on page 1 (which is
selectable).

Thank you,
Randy




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
Macro to select last row msnyc07 Excel Worksheet Functions 1 May 28th 10 12:19 AM
Macro to select last row Jacob Skaria Excel Worksheet Functions 0 May 27th 10 09:33 PM
Macro - select puiuluipui Excel Discussion (Misc queries) 4 May 19th 10 09:44 AM
Macro to select cells without a certain value and select a menu it Guy[_2_] Excel Worksheet Functions 9 January 2nd 09 05:21 PM
Select other workbook to select data in a macro. T Tromp Excel Programming 2 September 19th 03 01:43 PM


All times are GMT +1. The time now is 03:53 AM.

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

About Us

"It's about Microsoft Excel"