LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default very confusing

Hi

I have a module in a spreadsheet which executes a piece of code, see below

Set wRep = Worksheets("Report to Region")
wRep.Activate
Set R = wRep.Range("A20:A46")
R.Activate
enc = R.Find(What:=sIprojNo, After:=R.Cells(1, 1), LookIn:=xlValues,
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False, SearchFormat:=False).Activate
If enc = False Then
nRows = WorksheetFunction.CountA(R) + 1
R.Cells(nRows, 1) = sIprojNo
R.Cells(nRows, 2).Select
End If

Which works perfectly, later in the same spreadsheet, in a user form, on a
button to save the data that may be captures, I need to do the same data
check and paste the relevant field, if needed to the end of the list so I
copies and pasted the code andit doesnot work, see below

Set wRep = Worksheets("Report to Region")
wRep.Activate
Set R = wRep.Range("A20:A46")
R.Activate
enc = R.Find(What:=sIprojNo, After:=R.Cells(1, 1), LookIn:=xlValues,
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False, SearchFormat:=False).Activate
If enc = False Then
nRows = WorksheetFunction.CountA(R) + 1
R.Cells(nRows, 1) = sIprojNo
R.Cells(nRows, 2).Select
End If

This same code now returns a Run Time Error '91':

Object Variable or With block variable not set

I use Option Explicit so it cant be a variable, what else could it be, any
ideas or suggestions are most welcome.

in both instances, the variables are defined as follows

Dim sIprojNo As String
Dim wRep As Worksheet
Dim R As Range
Dim enc As Boolean
Dim nRows As Integer


 
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
Confusing spreadsheet Dan Wood Excel Discussion (Misc queries) 0 May 20th 10 05:09 PM
Confusing results Papa Jonah Excel Worksheet Functions 5 March 5th 10 10:38 PM
Menu confusing marriedhsdad New Users to Excel 3 January 18th 10 04:20 PM
V-/H- LOOKUP still confusing Andreas B Excel Worksheet Functions 3 June 5th 08 02:54 PM
Help please! I'm confusing myself..... Ray Excel Programming 2 June 22nd 07 03:30 PM


All times are GMT +1. The time now is 09:35 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"