Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Selecting a cell according to the cell value

Hello All VB expert

Need help with a Macro.

I would like to be able to select a cell according to a variable in a cell.
For example: Cell A1 31/04/2010.

Cell A3 = 31/05/2010
Cell A4 = 30/06/2010
Cell A5 = 31/07/2010
Cell A6 = 31/04/2010

In this case when I run the Marco, it will select Cell A6 because it is the
same value to Cell A1.

And if now Cell A1 = 31/05/2010, it will select Cell A3 because it is the
same value to Cell A1

If you need more information or my explanation is not clear please let me
know.

Thank you very much for your help.

Harn


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 464
Default Selecting a cell according to the cell value

See this page
http://www.ozgrid.com/VBA/find-dates.htm

Sub FindDate()
Dim strdate As String

strdate = Format(Range("A1"), "Short Date")

On Error Resume Next
Set rcell = Range("A2:A10000").Find _
(What:=CDate(strdate), After:=Range("A2"), _
LookIn:=xlFormulas, LookAt:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlNext _
, MatchCase:=False)
On Error GoTo 0
If rcell Is Nothing Then
MsgBox "Date cannot be found"
Else
Application.Goto rcell

End If

End Sub


--
Regards
Dave Hawley
www.ozgrid.com
"Harn88" wrote in message
...
Hello All VB expert

Need help with a Macro.

I would like to be able to select a cell according to a variable in a
cell.
For example: Cell A1 31/04/2010.

Cell A3 = 31/05/2010
Cell A4 = 30/06/2010
Cell A5 = 31/07/2010
Cell A6 = 31/04/2010

In this case when I run the Marco, it will select Cell A6 because it is
the
same value to Cell A1.

And if now Cell A1 = 31/05/2010, it will select Cell A3 because it is the
same value to Cell A1

If you need more information or my explanation is not clear please let me
know.

Thank you very much for your help.

Harn



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Selecting a cell according to the cell value

Try the below

Cells.Find(What:=Range("A1").Value, After:=Range("A1"), _
LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext).Activate

PS: Try recording a macro and edit to suit...

--
Jacob (MVP - Excel)


"Harn88" wrote:

Hello All VB expert

Need help with a Macro.

I would like to be able to select a cell according to a variable in a cell.
For example: Cell A1 31/04/2010.

Cell A3 = 31/05/2010
Cell A4 = 30/06/2010
Cell A5 = 31/07/2010
Cell A6 = 31/04/2010

In this case when I run the Marco, it will select Cell A6 because it is the
same value to Cell A1.

And if now Cell A1 = 31/05/2010, it will select Cell A3 because it is the
same value to Cell A1

If you need more information or my explanation is not clear please let me
know.

Thank you very much for your help.

Harn


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
Paste data of a cell to another cell by just selecting the source lamesakid5810 Excel Programming 2 April 1st 09 08:35 AM
Excel 2007 single cell selecting muliple cell Submit2s Excel Worksheet Functions 1 February 12th 09 04:52 PM
Selecting a cell entry based on cell validation selection Brutalius Excel Worksheet Functions 2 December 17th 08 03:44 AM
Transfer cell values to another cell by selecting button. Gryndar Excel Worksheet Functions 2 November 24th 08 02:21 AM
Selecting 10 charcters on one cell and pasting to another cell [email protected] Excel Programming 10 February 26th 07 07:56 PM


All times are GMT +1. The time now is 02:16 PM.

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"