ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Stuck on a validation loop (https://www.excelbanter.com/excel-programming/322114-stuck-validation-loop.html)

Stuart Luscombe

Stuck on a validation loop
 
Hi all,

It's been a few years since I've done any kind of VB programming (or any
programming for that matter), but I am trying to automate a reporting
process that I have to do every morning as part of my job.

What I am trying to achieve is to get the contents of a cell on one sheet
of a workbook (after importing data), check it against a cell on another
sheet, repeat the process for another cell but then make sure that the 2
cells that have been found are on the same row.

So at the moment it's something along these lines:

celldate = Worksheets("Sheet1").Cells(currentrow, currentcolumn)
MsgBox (celldate)

founddate = Worksheets("Primes & Outlets").Cells.Find(celldate)
MsgBox (founddate)

If founddate = celldate Then verifieddate = True

And the same goes for checking the 'day' as well.

The only problem being is that whereas there is only 1 01-FEB-05, there
are many THURSDAY(s). So what I want to do is check to make sure
something like founddate.Row = foundday.Row.

Having not written any code in such a long time I'm having difficulty
getting the syntax right for what I need to do...which is:

if foundday.Row < founddate.Row then
foundday = .FindNext(day)
until
foundday.Row = founddate.Row
EndIf

....or something like that, like I said, I've not done this for years.

Hope one of you can help
--
Stu



Tom Ogilvy

Stuck on a validation loop
 
Your description is lacking in the kind of detail necessary to provide a
focused solution, so in general.

Dim sStr as variant
Dim rng as Range
Dim fAddr as String
Dim fndcell as Range

sStr = "something"

set rng = Worksheets(1).Cells.Find(sStr)
if not rng is nothing then
fAddr = rng.Address
do
if rng.Value = "???" then ' test your condition
' condition met, save results and exit loop
set fndcell = rng
exit do
end if
set rng = worksheets(1).Cells.FindNext(rng)
Loop while rng.Address < fAddr
End if

msgbox fndcell.Address

--
Regards,
Tom Ogilvy


"Stuart Luscombe" wrote in message
.251...
Hi all,

It's been a few years since I've done any kind of VB programming (or any
programming for that matter), but I am trying to automate a reporting
process that I have to do every morning as part of my job.

What I am trying to achieve is to get the contents of a cell on one sheet
of a workbook (after importing data), check it against a cell on another
sheet, repeat the process for another cell but then make sure that the 2
cells that have been found are on the same row.

So at the moment it's something along these lines:

celldate = Worksheets("Sheet1").Cells(currentrow, currentcolumn)
MsgBox (celldate)

founddate = Worksheets("Primes & Outlets").Cells.Find(celldate)
MsgBox (founddate)

If founddate = celldate Then verifieddate = True

And the same goes for checking the 'day' as well.

The only problem being is that whereas there is only 1 01-FEB-05, there
are many THURSDAY(s). So what I want to do is check to make sure
something like founddate.Row = foundday.Row.

Having not written any code in such a long time I'm having difficulty
getting the syntax right for what I need to do...which is:

if foundday.Row < founddate.Row then
foundday = .FindNext(day)
until
foundday.Row = founddate.Row
EndIf

...or something like that, like I said, I've not done this for years.

Hope one of you can help
--
Stu






All times are GMT +1. The time now is 10:32 PM.

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