ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   finding a value (https://www.excelbanter.com/excel-programming/306572-finding-value.html)

tom[_6_]

finding a value
 
Hi,

How can I find a certain value, say x, in all the sheets
in a workbook or excel file? After finding it, I must
output all the sheet names that has x and its cell
location on a msgbox.

Thanks.

mark

finding a value
 
try this
sub findX()
dim i as integer
dim cell

set X=activecell.value
for i=1 to sheets.count
sheets(i).select
range("A1").select
set a=selection
range(a,a.specialcells(xlcelltypelastcell)).select
for each cell in selection
if cell.value=X.value then
msgbox "X.value is in sheet " & sheet.name
exit for
end if
next
next
end sub

regards
Mark
PS
see my Excel site
http://www.geocities.com/excelmarksway

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

How can I find a certain value, say x, in all the sheets
in a workbook or excel file? After finding it, I must
output all the sheet names that has x and its cell
location on a msgbox.

Thanks.
.



All times are GMT +1. The time now is 03:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com