Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default VBA: Find and adress cell

Hello!

I am trying to do the following: The user chooses a cell
via an InputBox (the cell contains a date); then the macro
needs to switch to another sheet an find this value/the
date in Column "A" and activate it. I just don't know how
to adress it ... Can anybody help?

Thanks,

Maria
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Find and adress cell

Hi Maria,

Try this

Dim ans
Dim c As Range

ans = InputBox("Input date")
If Not IsDate(ans) Then
MsgBox "Invalid date"
Exit Sub
Else
Worksheets("Sheet2").Activate
Set c = Columns(1).Find(ans, LookIn:=xlValues)
If Not c Is Nothing Then
c.Activate
End If
End If

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Maria" wrote in message
...
Hello!

I am trying to do the following: The user chooses a cell
via an InputBox (the cell contains a date); then the macro
needs to switch to another sheet an find this value/the
date in Column "A" and activate it. I just don't know how
to adress it ... Can anybody help?

Thanks,

Maria



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Find and adress cell

Many thanks, it worked out!

Maria


-----Original Message-----
Hi Maria,

Try this

Dim ans
Dim c As Range

ans = InputBox("Input date")
If Not IsDate(ans) Then
MsgBox "Invalid date"
Exit Sub
Else
Worksheets("Sheet2").Activate
Set c = Columns(1).Find(ans, LookIn:=xlValues)
If Not c Is Nothing Then
c.Activate
End If
End If

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Maria" wrote in

message
...
Hello!

I am trying to do the following: The user chooses a cell
via an InputBox (the cell contains a date); then the

macro
needs to switch to another sheet an find this value/the
date in Column "A" and activate it. I just don't know

how
to adress it ... Can anybody help?

Thanks,

Maria



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 318
Default VBA: Find and adress cell

Maria,
You could pass the date received from the message box to the following sub.
This assumes that the Programmatic name of the sheet you have the list on is
Sheet2 and that the range is from A1 to A100. Modify the code appropriately.

Sub Switch(ByVal d As Double)

Dim lRow&

On Error Resume Next
lRow = WorksheetFunction.Match(d, Sheet2.Range("A1:A100"), 0)
On Error GoTo 0

If lRow < 0 Then
Sheet2.Activate
Sheet2.Cells(lRow, 1).Select
End If

End Sub


"Maria" wrote:

Hello!

I am trying to do the following: The user chooses a cell
via an InputBox (the cell contains a date); then the macro
needs to switch to another sheet an find this value/the
date in Column "A" and activate it. I just don't know how
to adress it ... Can anybody help?

Thanks,

Maria

  #5   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default VBA: Find and adress cell

Many thanks for your help!

-----Original Message-----
Maria,
You could pass the date received from the message box to

the following sub.
This assumes that the Programmatic name of the sheet you

have the list on is
Sheet2 and that the range is from A1 to A100. Modify the

code appropriately.

Sub Switch(ByVal d As Double)

Dim lRow&

On Error Resume Next
lRow = WorksheetFunction.Match(d, Sheet2.Range

("A1:A100"), 0)
On Error GoTo 0

If lRow < 0 Then
Sheet2.Activate
Sheet2.Cells(lRow, 1).Select
End If

End Sub


"Maria" wrote:

Hello!

I am trying to do the following: The user chooses a

cell
via an InputBox (the cell contains a date); then the

macro
needs to switch to another sheet an find this value/the
date in Column "A" and activate it. I just don't know

how
to adress it ... Can anybody help?

Thanks,

Maria

.



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
How to extract zip code from a 1 cell adress line? Tippo22 Excel Discussion (Misc queries) 2 June 4th 08 07:39 AM
Excel Formula for Single Cell Adress Manyfaces Excel Worksheet Functions 2 June 8th 07 08:04 PM
Return cell adress for next non-blank cell in a range toreadore Excel Worksheet Functions 1 June 28th 06 12:37 PM
How do I put an adress in a cell in multiple lines?? Jill Excel Discussion (Misc queries) 5 June 21st 06 02:09 AM
Find value and adress acces[_6_] Excel Programming 1 January 23rd 04 12:42 PM


All times are GMT +1. The time now is 04:48 AM.

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"