ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   searching a cellvalue in a range (https://www.excelbanter.com/excel-programming/317897-searching-cellvalue-range.html)

newsbin.telenet.be

searching a cellvalue in a range
 
I am familiar with VBA in Access but not in XL.
I am looking for code (On Change event from a Spinbutton) which searches in
a range of cells (called "Schoolyear") the value which stays in cell B10.
If found the value of the cell should change to the value from B10
I started with the code from the Help file but I cannot adapt it.

With Worksheets(1).Range("a1:a500")
Set c = .Find(2, lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Value = 5
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
end withShould I declare variables and objects?
tks for helping
Michel



Don Guillett[_4_]

searching a cellvalue in a range
 
The code you found in HELP is good. It is looking in range("a1:a500"). So
change that. It is looking for the number 2. If found it is changing the
found cell to 5. Adapt to suit.

--
Don Guillett
SalesAid Software

"newsbin.telenet.be" wrote in message
...
I am familiar with VBA in Access but not in XL.
I am looking for code (On Change event from a Spinbutton) which searches

in
a range of cells (called "Schoolyear") the value which stays in cell B10.
If found the value of the cell should change to the value from B10
I started with the code from the Help file but I cannot adapt it.

With Worksheets(1).Range("a1:a500")
Set c = .Find(2, lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Value = 5
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
end withShould I declare variables and objects?
tks for helping
Michel






All times are GMT +1. The time now is 01:08 AM.

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