Hi everyone!!
I just signed up today to ask for help.
I really need help on VBA.
My data looks like below
123.jpg
Is there good way to change the data layout using VBA? I am literally new to VBA.
I would be super appreciated with your help!!
Hi everyone!!
I just signed up today to ask for help.
I really need help on VBA.
My data looks like below
123.jpg
Is there good way to change the data layout using VBA? I am literally new to VBA.
I would be super appreciated with your help!!
Welcome to the forum - please take a minute and read the FAQs at the link in my signature
Put this into a standard module, or tie it to button code
Option Explicit Sub TwoD_to_OneD() Dim rSrc As Range, rDest As Range Dim x As Long, y As Long, z As Long Application.ScreenUpdating = False Set rSrc = ActiveSheet.Range("B3").CurrentRegion ' <<<<<<<<<<<<<<<< change B3 Set rDest = ActiveSheet.Range("K3") ' <<<<<<<<<<<<<<<<< change K3 rDest.CurrentRegion.ClearContents z = 0 rDest.Offset(z, 0).Value = "X" rDest.Offset(z, 1).Value = "Y" rDest.Offset(z, 2).Value = "Z" For x = 2 To rSrc.Rows.Count For y = 2 To rSrc.Columns.Count z = z + 1 rDest.Offset(z, 0).Value = rSrc.Cells(x, 1).Value rDest.Offset(z, 1).Value = rSrc.Cells(1, y).Value rDest.Offset(z, 2).Value = rSrc.Cells(x, y).Value Next y Next x Application.ScreenUpdating = True End Sub
---------------------------------------------------------------------------------------------------------------------
Paul
Remember: Tell us WHAT you want to do, not HOW you think you want to do it
1. Use [CODE] ....[/CODE ] Tags for readability
[CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
2. Upload an example
Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
3. Mark the thread as [Solved] when you have an answer
Thread Tools (on the top right corner, above the first message)
4. Read the Forum FAQ, especially the part about cross-posting in other forums
http://www.vbaexpress.com/forum/faq...._new_faq_item3
Thank you!!