Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
needyourhelp
 
Posts: n/a
Default syntax question - cell references in VB code

Given the following code (found on this site..)

With ActiveSheet.Range("B:B")
Set FoundCell = .Find(what:="whatever", _
after:=.Cells(.Cells.Count), _
LookIn:=xlFormulas, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False)
End With

How do I tell VB to look in Cell H1 for the what:="whatever" ?

ie. I want to use the value found in the Cell H1 not the text "whatever"

I've tried every combination of H1, H1:H1, $H1, Range(H1), Range(H1:H1),
Range("H1"),etc....

All generate compile errors, syntax errors, or runtime errors....

Forgive the simple question, but I'm not VB literate and I don't have a
manual handy.

  #2   Report Post  
JE McGimpsey
 
Posts: n/a
Default

One way:

With ActiveSheet.Range("B:B")
Set FoundCell = .Find(What:=ActiveSheet.Range("H1").Value, _
After:=.Cells(.Cells.Count), _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
End With



In article ,
needyourhelp wrote:

Given the following code (found on this site..)

With ActiveSheet.Range("B:B")
Set FoundCell = .Find(what:="whatever", _
after:=.Cells(.Cells.Count), _
LookIn:=xlFormulas, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False)
End With

How do I tell VB to look in Cell H1 for the what:="whatever" ?

ie. I want to use the value found in the Cell H1 not the text "whatever"

I've tried every combination of H1, H1:H1, $H1, Range(H1), Range(H1:H1),
Range("H1"),etc....

All generate compile errors, syntax errors, or runtime errors....

Forgive the simple question, but I'm not VB literate and I don't have a
manual handy.

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
Unable to Copy COUNTA() with cell references EugenioB Excel Worksheet Functions 1 February 16th 05 01:07 PM
Finding Cell References Zokess Excel Discussion (Misc queries) 2 February 4th 05 04:52 PM
Excel: how to formulate conditional cell references centraloffice Excel Worksheet Functions 1 December 10th 04 08:57 PM
Transferring cell content between workbooks using cell references Kiwi Mike Excel Discussion (Misc queries) 2 November 27th 04 11:31 PM
GET.CELL Biff Excel Worksheet Functions 2 November 24th 04 07:16 PM


All times are GMT +1. The time now is 12:30 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"