Find function doesn't work after form unload?

HannaH021

New Member
Joined
Sep 5, 2017
Messages
3
Hi

I have this formula to find a row number

Code:
IDRow = MySheet.Range("A1:A10").Find(Trim("ID"), LookIn:=xlFormulas).Row

The method from which this line is called passes the sheet as a parameter, so I know that the sheet is always the right one.

I call this line after either of two things (see sample code below)
(1) if there is an option to choose from, then load a form and allow the user to choose a value. <<<< The find function returns 0!
(2) If there is a single option then just paste the single option directly in the cell matching the IDRow found using the find function. <<<< this works fine, and the find function finds the value.

Code:
If UBound(TArray) > 0 Then                
                FormControls.populateLabelsForm (TArray)
            Else
                IDRow = MySheet.Range("A1:A10").Find(Trim("ID"), LookIn:=xlFormulas).Row
                TVCol = MySheet.Range(MySheet.Cells(IDRow, 1), MySheet.Cells(IDRow, 30)).Find("TV", LookIn:=xlValues).Column
                MySheet.Cells(TargetCell.Row, TVCol).Value = CStr(TArray(0))
            End If

Even worse... when I debug and I stop at the End If above... then I pull the execution cursor to repeat the execution, it returns the correct value for IDRow !! :confused:

You can see that I have Trim there, because I'm trying to see if there the format is bothering it.. I removed all formatting, and still it is inconsistent :( ...

I'm very confused... anything you'd suggest that I look for?

Thanks for your time.
HannaH
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Welcome to the board.

Is there a reason for IDRow using LookIn:=xlFormulas but for TVCol using LookIn:=xlValues? Try xlValues for both
 
Last edited:
Upvote 0
I'm afraid I'm not sure what you mean by you copied the wrong code and can't edit.

Where is the code and why can't you edit it?
 
Upvote 0
I found the error... it is in the event handler...

Apologies for the wrong code earlier... not being able to edit is a bit strange, 10mins have not even passed :/
 
Upvote 0
Apologies for the wrong code earlier... not being able to edit is a bit strange, 10mins have not even passed :/
New members do not have edit ability. Once you make a bunch of posts, that will change.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top