473,395 Members | 1,460 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Error-Object variable or with block variable not set!!

1
Hi, I'm new to VB..
Currently I want to do a test and program as the following..But nomatter how hard I try I always end up with this error message-object variable or with block variable not se...............I'm really exhausted for that.....

Pls help me!!

Sub test()
Worksheets("Testing page").Activate
Dim counter1 As Integer, counter2 As Integer, counter4 As Integer, counter5 As Integer, hang As Integer, lie As Integer
Dim c As Range, d As Range
Dim cellstring1 As String, cellstring2 As String
counter4 = 9
For counter1 = 1 To 228

For counter2 = 1 To 30
counter4 = counter2 + counter4
If Worksheets("Testing page").Cells(counter4, 3) = "" Then

Exit For
End If
cellstring1 = Worksheets("Testing page").Cells(counter4, 3)
With Worksheets("Testing page").Range("F10:F20")
Set c = .Find(cellstring1, LookIn:=xlValues)
End With
hang = c.Row
For counter5 = 1 To 5
If Worksheets("Testing page").Cells(hang, 8) = Worksheets("Testing page").Cells(counter4, 1) Then
cellstring2 = Worksheets("Testing page").Cells(hang, 6)
With Worksheets("Testing page").Range("J1:o1")
Set d = .Find(cellstring2, LookIn:=xlValues)
End With
lie = d.Column
Worksheets("Testing page").Cells(counter4, lie) = "*"
End If
hang = hang + 1
If Worksheets("Testing page").Cells(hang, 8) = "" Then
Exit For
End If
Next counter5
Next counter2

counter2 = counter4
Next counter1

End Sub
May 24 '07 #1
1 1925
Hi, I'm new to VB..
Currently I want to do a test and program as the following..But nomatter how hard I try I always end up with this error message-object variable or with block variable not se...............I'm really exhausted for that.....

Pls help me!!

Sub test()
Worksheets("Testing page").Activate
Dim counter1 As Integer, counter2 As Integer, counter4 As Integer, counter5 As Integer, hang As Integer, lie As Integer
Dim c As Range, d As Range
Dim cellstring1 As String, cellstring2 As String
counter4 = 9
For counter1 = 1 To 228

For counter2 = 1 To 30
counter4 = counter2 + counter4
If Worksheets("Testing page").Cells(counter4, 3) = "" Then

Exit For
End If
cellstring1 = Worksheets("Testing page").Cells(counter4, 3)
With Worksheets("Testing page").Range("F10:F20")
Set c = .Find(cellstring1, LookIn:=xlValues)
End With
hang = c.Row
For counter5 = 1 To 5
If Worksheets("Testing page").Cells(hang, 8) = Worksheets("Testing page").Cells(counter4, 1) Then
cellstring2 = Worksheets("Testing page").Cells(hang, 6)
With Worksheets("Testing page").Range("J1:o1")
Set d = .Find(cellstring2, LookIn:=xlValues)
End With
lie = d.Column
Worksheets("Testing page").Cells(counter4, lie) = "*"
End If
hang = hang + 1
If Worksheets("Testing page").Cells(hang, 8) = "" Then
Exit For
End If
Next counter5
Next counter2

counter2 = counter4
Next counter1

End Sub
Hi, i think you need to explain more like what is worksheet and what properties is in it. However this usally means two things
1. you havn't declared a variable, or there are two variable with the same name
2. you have intanciated a new class, or set it.

Example
with a recordset

Dim rs1 as adodb.recordset

Set rs1 = new recordset

you have possibly missed this out or set an object

Set datacombo.boundcoulom
May 24 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: MARK | last post by:
When i attempt to set my 'picture' background for my sub-form i get the error "OBJECT BLOCK OR WITH BLOCK VARIABLE NOT SET". The main form has a background set using the 'picture' in the...
3
by: Joe Schwartz | last post by:
All, Could somebody please help me out here. I am getting an "Object variable or With block variable not set" error with the following code. This happens when I enter a value into the "ponum"...
4
by: nelsonchang | last post by:
Dear all, I wrote the VB code in a "button press event" as below in which is retrieve data from SQL server and insert the data into Excel. After that, I would call Excel "subtotal" API to build a...
6
by: Neo Geshel | last post by:
I am trying to deal with an image in code-behind. I consistently get the following error: Server Error in '/' Application. Object variable or With block variable not set. Description: An...
3
by: Richard Hollenbeck | last post by:
I've marked the line in this subroutine where I've been getting this error. It may be something stupid but I've been staring at this error trying to fix it for over an hour. I'm pretty sure the...
1
by: abhijmenbumca07 | last post by:
Object variable or With block variable not set. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information...
4
by: BrianAdev | last post by:
Why It throw an error of <Object variable or With block variable not set> set objAccess = GetObject(strMdbPath) objAccess.DoCmd.SetWarning False objAccess.DoCmd.OpenReport strReportName, 0 'It...
3
by: Newbie19 | last post by:
I'm trying to get a list of all subfolders in a folder on a share drive, but I keep on getting this error message: Object variable or With block variable not set. Description: An unhandled...
5
by: Al G | last post by:
Hi, I'm converting a bit of POP3 VB6 code to VB2005, and have run into this error with the following code. Can someone help me find out what I'm missing/doing wrong? 'holds the attachments...
1
by: akaess | last post by:
I am trying to merge information from the the database into word documents using the following methods but it keeps giving the error 91: Object Variable or With Block Variable not set. could anybody...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.