Range syntax

VBABEGINER

Well-known Member
Joined
Jun 15, 2011
Messages
1,232
Can any one please tell me the right syntax for this.

Range(Cells(7, 11), Cells(p1, 11)).Select
Selection.Rows.group

I got error -

1004
Application defined or object defined error
 
In your code, after you have found the value of p1 insert this line of code

Code:
MsgBox p1

then run your code. what does the msgbox give as the value for p1?
 
Upvote 0

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Vog Sir,

Yesterday i was trying dis. but the same as i unware about the syntax of "Range(cell1,cell2)" i am unble to do this. I hope the following code will also make us some help.

Public Function casting()

Dim inti As Integer
inti = 7

Do Until ActiveSheet.Cells(inti, 11) = ""
If ActiveSheet.Cells(inti, 11) <> ActiveSheet.Cells(inti + 1, 11) Then
ActiveSheet.Cells.Select
Selection.Rows.Group
End If
inti = inti + 1
Loop
End Function
 
Upvote 0
If you correct your Dim statement to

Code:
Dim p1 As Integer, p2 As Integer, p3 As Integer, p4 As Integer, p5 As Integer, p6 As Integer, p7 As Integer

Does the msgbox display 0? If so that is why you are getting an error - p1 must be greater than or equal to 7.
 
Upvote 0
Ohhhh....i got a littele bit.

For jam = 7 To iam
If Cells(jam, 11) = "2" Then
p1 = Cells(jam - 1, 11) '............last 1's
Else
If Cells(jam, 11) = "3" Then ......this is again counting from start number.
p2 = Cells(jam - 1, 11) '............last 2's
Else
 
Upvote 0
So, you'll need to investigate why it is giving 0 and not the value that you expect.
 
Upvote 0
Perhaps it should be

Code:
If Cells(jam, 11).Value = 2 Then

(no "" around the 2)
 
Upvote 0
No sir, see we took value again started from starting value. So this also cause the error? I am sorry but i am trying to just find out y this p1 p2 not pick the values?
 
Upvote 0

Forum statistics

Threads
1,215,681
Messages
6,126,191
Members
449,298
Latest member
Jest

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