Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default Find Date error message

HI!,

I am trying to find a date from an activecell but i get the error message


"object variale or with block variable not set"

From the bellow Sub

Sub MENB()

Dim LASTROW As Long
Dim abcd As range

Sheets("MONTHS TO UPDATE").Select
LASTROW = Cells(Rows.Count, 1).End(xlUp).Row
For nb = LASTROW To 1 Step -1
Cells(nb, 1).Select
If Cells(nb, 2).Value Like "*X" Then
GoTo GETOUT
End If
Next nb
GETOUT:
Set abcd = ActiveCell
Sheets("Copy Paste Special").Select
Range("a1").Select
Cells.Find(What:=abcd, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate

End Sub

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200609/1

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Find Date error message

My first guess would be that you have Option Explicit at the top of each
module. If a variable is not Dimmed, then you will get that error. Add this
to your code for variable nb:
Sub MENB()

Dim LASTROW As Long
Dim abcd As range

Dim nb As Long

Mike F

"FIRSTROUNDKO via OfficeKB.com" <u15639@uwe wrote in message
news:66f53971c2256@uwe...
HI!,

I am trying to find a date from an activecell but i get the error message


"object variale or with block variable not set"

From the bellow Sub

Sub MENB()

Dim LASTROW As Long
Dim abcd As range

Sheets("MONTHS TO UPDATE").Select
LASTROW = Cells(Rows.Count, 1).End(xlUp).Row
For nb = LASTROW To 1 Step -1
Cells(nb, 1).Select
If Cells(nb, 2).Value Like "*X" Then
GoTo GETOUT
End If
Next nb
GETOUT:
Set abcd = ActiveCell
Sheets("Copy Paste Special").Select
Range("a1").Select
Cells.Find(What:=abcd, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate

End Sub

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200609/1



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Find Date error message

Hi
If the Find part doesn't find anything then you will get an error. Do
on error resume next
Cells.Find(What:=abcd, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
on error goto 0

This will ignore the error within your loop, do nothing to the cells,
and go onto the next loop value, if that is what you want?
regards
Paul

FIRSTROUNDKO via OfficeKB.com wrote:
HI!,

I am trying to find a date from an activecell but i get the error message


"object variale or with block variable not set"

From the bellow Sub

Sub MENB()

Dim LASTROW As Long
Dim abcd As range

Sheets("MONTHS TO UPDATE").Select
LASTROW = Cells(Rows.Count, 1).End(xlUp).Row
For nb = LASTROW To 1 Step -1
Cells(nb, 1).Select
If Cells(nb, 2).Value Like "*X" Then
GoTo GETOUT
End If
Next nb
GETOUT:
Set abcd = ActiveCell
Sheets("Copy Paste Special").Select
Range("a1").Select
Cells.Find(What:=abcd, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate

End Sub

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200609/1


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error message needed if incorrect Date Of Birth (DOB) entered Craig Excel Worksheet Functions 5 January 27th 10 08:24 PM
Disable find files error message for missing links on opening WB RAZA Excel Discussion (Misc queries) 3 May 10th 06 12:32 PM
change error message when no more for "find" in macro to find swyltm Excel Programming 1 January 13th 06 05:16 PM
Input Date Error Message Dominique Feteau[_2_] Excel Programming 2 December 4th 04 08:00 AM
Find generates error message James Houston Excel Programming 3 April 28th 04 07:55 AM


All times are GMT +1. The time now is 04:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"