Solved

VBA Excel 2010 - Group sections on a worksheet

Posted on 2016-07-24
2
47 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 51

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

707 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