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
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Here is the full code which i was tryed from last two days.
Sir,
even i posted the "group syntax query" also. but i didnt get the answer for that.
By doing lot of R&D i reach till here now.

now this gives mi the error as mentioned previous post.

Reason for displaying code, for your master's look offcourse will provide some great idea of coding.


Public Function tester()
Dim iam As Long
Dim jam
Dim p1, p2, p3, p4, p5, p6, p7 As Integer
iam = Range("K" & Rows.Count).End(xlUp).Row
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
p2 = Cells(jam - 1, 11) '............last 2's
Else
If Cells(jam, 11) = "4" Then
p3 = Cells(jam - 1, 11) '............last 3's
Else
If Cells(jam, 11) = "5" Then
p4 = Cells(jam - 1, 11) '............last 4's
Else
If Cells(jam, 11) = "6" Then
p5 = Cells(jam - 1, 11) '............last 5's
Else
If Cells(jam, 11) = "7" Then
p6 = Cells(jam - 1, 11) '............last 6's
Else
If Cells(jam, 11) = "" Then
p7 = Cells(jam - 1, 11) '............last 7's
End If
End If
End If
End If
End If
End If
End If
Next
'Range(Cells(7, 11), Cells(p1, 11)).Select 'will group 1 no.
'Selection.Rows.Group
Rows("7:" & p1).Group
Range(Cells(p1 + 1, 11), Cells(p2, 11)).Select 'will group 2 no.
Selection.Rows.Group
Range(Cells(p2 + 1, 11), Cells(p3, 11)).Select 'will group 3 no.
Selection.Rows.Group
Range(Cells(p3 + 1, 11), Cells(p4, 11)).Select 'will group 4 no.
Selection.Rows.Group
Range(Cells(p4 + 1, 11), Cells(p5, 11)).Select 'will group 5 no.
Selection.Rows.Group
Range(Cells(p5 + 1, 11), Cells(p6, 11)).Select 'will group 6 no.
Selection.Rows.Group
Range(Cells(p6 + 1, 11), Cells(p7, 11)).Select 'will group 7 no.
Selection.Rows.Group
End Function
 
Upvote 0
col C contains 6 different types.
on
on-off
on-off-start and 3 more etc.

When report generate, they offcource come in random order. For grouping this type, i did first sort on this types by giving numbers in col k. for example -

on ..................1
on-off..............2
on-off-start......3

sort order keep my report in ascending order like -

col A...........col C................col K
abc.............on ..................1
pqr..............on ..................1
poi..............on-off..............2
mmm...........on-off..............2
zzz...........on-off..............2
qqq...........on-off-start......3
aaa...........on-off-start......3

after doing this i need to group this by type i.e- in col C wise.

col A...........col C................col K
+.............on ..................1
+..............on-off..............2
+...........on-off-start.........3

P1, p2 values are that read the numbering in col K.

if col k cell come value = 2 then
cells-1 = till the value "1"
I assign them p1

Hope sir this will make you more clear scenario.
 
Upvote 0
I am trying to find change number.
In col K -
if cells(j,11) <> cells(j+1,11) then

trying to find this cell value "cells(j+1,11)". therefore give p1 etc. naming for 6 types.
 
Upvote 0
What does the MsgBox give you?

Code:
MsgBox p1
Rows("7:" & p1).Group
 
Upvote 0

Forum statistics

Threads
1,213,510
Messages
6,114,048
Members
448,543
Latest member
MartinLarkin

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