Solved

VBA Excel 2010 - Group sections on a worksheet

Posted on 2016-07-24
2
40 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
2 Comments
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

831 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