I am looking for ideas on how to split my data in the attached spreadsheet.
Thank you in advance.
Kerry
![]() |
Patch reliability is unclear, but widespread attacks make patching prudent. Go ahead and patch, but watch out for potential problems. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Amalgamate Data Formula
My apology for the lack of information.
What I am trying to do is to create rows from the region columns. So where SA2_DESC has a multiple Regions each one will become a row. The intention is to transfer to the new format. I have removed the total column as it unnecessary for the purposes of this exercise. I have attached another example that hopefully is more meaningful.
Here’s some untested code to convert the sheet – I don’t have Excel to test, but it looks OK.
Don’t forget to test it on a copy of your data.
cheers, Paul
Public Sub ReformatSheet() Dim LastRow As Long, I As Long, J As Long SourceRange = “A2” ‘Change this to the destination column DestRange = “AA1” ‘Change this to the destination column NumCols = 7 ‘Change this if more than 7 columns of data SourceRow = Row(SourceRange) SourceCol = Column(SourceRange) DestRow = Row(DestRange) DestCol = Column(DestRange) LastRow = ActiveSheet.Cells(Rows.Count, SourceCol).End(xlUp).Row For I = SourceRow To LastRow For J = 0 to NumCols – 3 ‘Ignoring first 2 columns as they are constant If Cells(I, J + 3) > 0 Then DestRow = DestRow + J Cells(J, DestCol) = Cells(I, SourceCol) Cells(J, DestCol + 1) = Cells(I, SourceCol + 1) Cells(J, J + 3) = Cells(SourceRow, SourceCol + 2) Cells(J, J + 3) = Cells(I, SourceCol + 2) End If Next J DestRow = DestRow + 1 Next I End Sub
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.
Notifications