?
Solved

VBA Excel 2010 - Group sections on a worksheet

Posted on 2016-07-24
2
Medium Priority
?
57 Views
Last Modified: 2016-07-25
Dear Experts,

Could you please have a short look on the attached picture and file, basically I have a worksheet in Excel where the product sections as one group are separated with an empty line:
The exampleGroupingSections.xlsx

Could you advise which VBA could assign increasing numbers to these groups, like that is marked with green color in column A?

Thanks in advance,
0
Comment
Question by:csehz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 53

Accepted Solution

by:
Rgonzo1971 earned 2000 total points
ID: 41727082
Hi,

pls try

Sub macro()
Idx = 1
For Each c In Range(Range("A2"), Range("A" & Range("B" & Rows.Count).End(xlUp).Row))
    If c.Offset(, 1) = "" Then
    
    Else
        c.Value = Idx
        If c.Offset(1, 1) = "" Then Idx = Idx + 1
    End If
Next
End Sub

Open in new window

Regards
0
 
LVL 1

Author Closing Comment

by:csehz
ID: 41727100
Thank you that is awesome
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question