Hi Friends,
I have a problem on a simple code. I hope you can help me. I am getting Run-Time error '91' error.
Thank you. Please see attached file.
Regards
Hi Friends,
I have a problem on a simple code. I hope you can help me. I am getting Run-Time error '91' error.
Thank you. Please see attached file.
Regards
Funny thing is, if you set it to lookin xlFormulas, it seems to work.
1. The 'real' value in J2 is 43999 since Excel stores dates as serial numbers so that's why xlFormulas works
2. You Dim MyDate as a Date, but assign a string so Excel nicely (?) converts it for you
3. You have Custom Number formatting on row 2 (dd-mmm-yy) so I think .Find returns Nothing if you don't give it a string it can locate
4. The Worksheets(I).Rows(2).Nothing is likely what causes the Error 91 since it doesn't have a .Column
Dim MyDate As Date ' <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 'MyDate = "2019-05-14" MyDate = DateSerial(2019, 5, 14) ' <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 'MyDate = Application.inputbox("Put Date:", "Choose Date") 'two ways <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Colx = Worksheets(i).Rows(2).Find(what:=Format(MyDate, "dd-mmm-yy"), LookIn:=xlValues, lookat:=xlWhole, MatchCase:=False).Column or Colx = Worksheets(i).Rows(2).Find(what:=MyDate, LookIn:=xlFormulas, lookat:=xlWhole, MatchCase:=False).Column ' Define Column
---------------------------------------------------------------------------------------------------------------------
Paul
Remember: Tell us WHAT you want to do, not HOW you think you want to do it
1. Use [CODE] ....[/CODE ] Tags for readability
[CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
2. Upload an example
Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
3. Mark the thread as [Solved] when you have an answer
Thread Tools (on the top right corner, above the first message)
4. Read the Forum FAQ, especially the part about cross-posting in other forums
http://www.vbaexpress.com/forum/faq...._new_faq_item3
Thank you Paul,
You are right, it was problem of DIM Type. It is solved.
Regards
How can I change the position of this post as "SOLVED". I did not find it ...
#3 in my signature
---------------------------------------------------------------------------------------------------------------------
Paul
Remember: Tell us WHAT you want to do, not HOW you think you want to do it
1. Use [CODE] ....[/CODE ] Tags for readability
[CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
2. Upload an example
Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
3. Mark the thread as [Solved] when you have an answer
Thread Tools (on the top right corner, above the first message)
4. Read the Forum FAQ, especially the part about cross-posting in other forums
http://www.vbaexpress.com/forum/faq...._new_faq_item3