#1   Report Post  
thephoenix12
 
Posts: n/a
Default cell searching


Hi,

I am looking for a way to search through a certain cell on multiple
worksheets, for example: B5 on Sheet 3 through Sheet 45, and when the
cell has a number in it (it is either going to be blank or have a
number), a message box pops up displaying the worksheet name. I want
to insert a button or something that the user can press to start the
search, then the user will input the cell to search in and the program
will run, displaying message boxes for every worksheet that has a
number (only a few will). I would be very very grateful for any help
with this!

Thanks,
-Steve


--
thephoenix12
------------------------------------------------------------------------
thephoenix12's Profile: http://www.excelforum.com/member.php...o&userid=24336
View this thread: http://www.excelforum.com/showthread...hreadid=380524

  #2   Report Post  
anilsolipuram
 
Posts: n/a
Default


this macro should do that



Sub MACRO9()
Dim W As Worksheet
Dim VAL As Variant
VAL = InputBox("Enter which cell to search")
For Each W In Worksheets
W.Select
If (IsNumeric(Range(VAL).Value) And Range(VAL).Value < "")
Then
MsgBox "found number in " & W.Name
End If
Next
End Sub


--
anilsolipuram
------------------------------------------------------------------------
anilsolipuram's Profile: http://www.excelforum.com/member.php...o&userid=16271
View this thread: http://www.excelforum.com/showthread...hreadid=380524

  #3   Report Post  
thephoenix12
 
Posts: n/a
Default


Thanks so much for that macro. Is there a way to have it search all but
one worksheet? The first worksheet in the database is a summary with
differently arranged cells, which messes up the search. If there was a
way to have the macro search all the worksheets but that one then it
would run perfectly.

Thanks,
-Steve


--
thephoenix12
------------------------------------------------------------------------
thephoenix12's Profile: http://www.excelforum.com/member.php...o&userid=24336
View this thread: http://www.excelforum.com/showthread...hreadid=380524

  #4   Report Post  
anilsolipuram
 
Posts: n/a
Default


I am assumming the worksheet you want to skip searching is "Summary",
you can change in the code if the name of worksheet is different than
Summary

Sub MACRO9()
Dim W As Worksheet
Dim VAL,sh_skip As Variant
sh_skip="Summary" 'sheetname to skip
VAL = InputBox("Enter which cell to search")
For Each W In Worksheets
W.Select
if w.name<sh_skip then
If (IsNumeric(Range(VAL).Value) And Range(VAL).Value < "") Then
MsgBox "found number in " & W.Name
End If
end if
Next
End Sub


--
anilsolipuram
------------------------------------------------------------------------
anilsolipuram's Profile: http://www.excelforum.com/member.php...o&userid=16271
View this thread: http://www.excelforum.com/showthread...hreadid=380524

  #5   Report Post  
thephoenix12
 
Posts: n/a
Default


Thank you very very much that works perfectly! I know practically
nothing about Visual Basic, so I'm trying to understand this code...

"If W.Name < sh_skip Then", how does this line make the program skip
the summary worksheet?

"If (IsNumeric(Range(VAL).Value) And Range(VAL).Value < "") Then", for
this line, does the And Range(VAL).Value < "" make the code skip over
the cells with no text in them, which the "" represents? Do these: <
make the code skip what they are referring to?

Sorry to keep bothering you, I just want to try and learn exactly how
this code is working.

Thanks,
-Steve


--
thephoenix12
------------------------------------------------------------------------
thephoenix12's Profile: http://www.excelforum.com/member.php...o&userid=24336
View this thread: http://www.excelforum.com/showthread...hreadid=380524



  #6   Report Post  
anilsolipuram
 
Posts: n/a
Default


For Each W In Worksheets ---- (1)
W.Select ---- (2)
if w.name<sh_skip then ------(3)
If (IsNumeric(Range(VAL).Value) And Range(VAL).Value < "") Then
----(4)
MsgBox "found number in " & W.Name ----(5)
End If-----(6)
end if----(7)
Next----(8)

(1)- looping through all the worksheets
(2)-selects a worksheet
(3)w.name<sh_skip i.e if worksheet name is not equal to
sh_skip(Summary) then only execute the code(next line) otherwise goes
to line (7)
(4)checks whether numeric and as no text(Range(VAL).Value < ""), if
true goes to (5)
(5) alerts with worksheet name
(6) ,(7) end of id statements
(8) end looping through worksheets
(6)


--
anilsolipuram
------------------------------------------------------------------------
anilsolipuram's Profile: http://www.excelforum.com/member.php...o&userid=16271
View this thread: http://www.excelforum.com/showthread...hreadid=380524

  #7   Report Post  
thephoenix12
 
Posts: n/a
Default


Thanks anilsolipuram!


--
thephoenix12
------------------------------------------------------------------------
thephoenix12's Profile: http://www.excelforum.com/member.php...o&userid=24336
View this thread: http://www.excelforum.com/showthread...hreadid=380524

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
Maintaining cell reference after sorting GRITS Excel Discussion (Misc queries) 2 April 30th 23 07:42 PM
Pasting Word table cell with paragraph markers into single Excel c Steve Excel Discussion (Misc queries) 1 June 16th 05 11:26 PM
Can I use the contents of a cell to satisfy the result_vector arg. robh_2 Excel Worksheet Functions 3 February 24th 05 08:14 PM
inserting data from a row to a cell, when the row number is specified by a formula in a cell [email protected] New Users to Excel 2 January 6th 05 07:18 AM
VLookup resulting in a blank cell... KempensBoerke Excel Worksheet Functions 1 October 28th 04 09:57 PM


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