Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 519
Default Compile error

Hello from Steved

Below is giving me a compile error.

The below macro objective is to bring up an input box, I enter an input say
009 it then searches Column C:C once found say on Col C Row 238 it then
invites me to type 4567 which puts it the Col B Row 238.

What Have I not got right please. Thankyou.

Set RgFound = RgToSearch.Find(what:=res, LookIn:=xlValues,

Sub FindPart()
Dim res
Dim RgToSearch As Range, RgFound As Range

Set RgToSearch = ActiveSheet.Range("C:C")

res = Application.InputBox("Enter Part Number", "Find Part", , , , , , 2)
If res = "False" Then Exit Sub 'exit if Cancel is clicked
res = Trim(UCase(res))
If res = "" Then Exit Sub 'exit if no entry and OK is clicked

Set RgFound = RgToSearch.Find(what:=res, LookIn:=xlValues,
lookat:=xlWhole, MatchCase:=False)
If RgFound Is Nothing Then
MsgBox "Part " & res & " not found."
Else
Application.Goto Reference:=RgFound.Offset(0, -1).Address(True, True,
xlR1C1)
End If

End Sub



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Compile error

Your code works for me, once the line wrap problem was taken care
of.

Set RgFound = RgToSearch.Find(what:=res, LookIn:=xlValues, _
lookat:=xlWhole, MatchCase:=False)

Note the _ character (preceeded by a space) at the end of the
first line of text.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Steved" wrote in message
...
Hello from Steved

Below is giving me a compile error.

The below macro objective is to bring up an input box, I enter
an input say
009 it then searches Column C:C once found say on Col C Row 238
it then
invites me to type 4567 which puts it the Col B Row 238.

What Have I not got right please. Thankyou.

Set RgFound = RgToSearch.Find(what:=res, LookIn:=xlValues,

Sub FindPart()
Dim res
Dim RgToSearch As Range, RgFound As Range

Set RgToSearch = ActiveSheet.Range("C:C")

res = Application.InputBox("Enter Part Number", "Find Part",
, , , , , 2)
If res = "False" Then Exit Sub 'exit if Cancel is clicked
res = Trim(UCase(res))
If res = "" Then Exit Sub 'exit if no entry and OK
is clicked

Set RgFound = RgToSearch.Find(what:=res, LookIn:=xlValues,
lookat:=xlWhole, MatchCase:=False)
If RgFound Is Nothing Then
MsgBox "Part " & res & " not found."
Else
Application.Goto
Reference:=RgFound.Offset(0, -1).Address(True, True,
xlR1C1)
End If

End Sub





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 519
Default Compile error

Thankyou very much Chip.

"Chip Pearson" wrote:

Your code works for me, once the line wrap problem was taken care
of.

Set RgFound = RgToSearch.Find(what:=res, LookIn:=xlValues, _
lookat:=xlWhole, MatchCase:=False)

Note the _ character (preceeded by a space) at the end of the
first line of text.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Steved" wrote in message
...
Hello from Steved

Below is giving me a compile error.

The below macro objective is to bring up an input box, I enter
an input say
009 it then searches Column C:C once found say on Col C Row 238
it then
invites me to type 4567 which puts it the Col B Row 238.

What Have I not got right please. Thankyou.

Set RgFound = RgToSearch.Find(what:=res, LookIn:=xlValues,

Sub FindPart()
Dim res
Dim RgToSearch As Range, RgFound As Range

Set RgToSearch = ActiveSheet.Range("C:C")

res = Application.InputBox("Enter Part Number", "Find Part",
, , , , , 2)
If res = "False" Then Exit Sub 'exit if Cancel is clicked
res = Trim(UCase(res))
If res = "" Then Exit Sub 'exit if no entry and OK
is clicked

Set RgFound = RgToSearch.Find(what:=res, LookIn:=xlValues,
lookat:=xlWhole, MatchCase:=False)
If RgFound Is Nothing Then
MsgBox "Part " & res & " not found."
Else
Application.Goto
Reference:=RgFound.Offset(0, -1).Address(True, True,
xlR1C1)
End If

End Sub






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
help with this error-Compile error: cant find project or library JackR Excel Discussion (Misc queries) 2 June 10th 06 09:09 PM
VBAProject name compile error, not defined at compile time Matthew Dodds Excel Programming 1 December 13th 05 07:17 PM
error message: compile error, argument not optional Pierre via OfficeKB.com Excel Programming 3 September 5th 05 03:45 PM
How do I get rid of "Compile error in hidden module" error message David Excel Discussion (Misc queries) 4 January 21st 05 11:39 PM


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