VBA Copy and Transpose to merged cells - my bad but working solution

Melimob

Active Member
Joined
Oct 16, 2011
Messages
396
Office Version
  1. 365
.. sorry for so many posts but I couldn't find a workaround to transpose to merged cells but thought I'd share my basic and probably risky code.
As you can see, very limited knowledge and I know the range could change but will have to call that out.

Code:
Sub TransposeValue()


Worksheets("COD Mapping").Rows("1").ClearContents
Worksheets("COD Mapping").Range("C1").Value = "Client"


Worksheets("COD Mapping").Range("D1").Value = Worksheets("HRG Clients ").Range("C3").Value
Worksheets("COD Mapping").Range("f1").Value = Worksheets("HRG Clients ").Range("C4").Value
Worksheets("COD Mapping").Range("h1").Value = Worksheets("HRG Clients ").Range("C5").Value
Worksheets("COD Mapping").Range("j1").Value = Worksheets("HRG Clients ").Range("C6").Value
Worksheets("COD Mapping").Range("l1").Value = Worksheets("HRG Clients ").Range("C7").Value
Worksheets("COD Mapping").Range("n1").Value = Worksheets("HRG Clients ").Range("C8").Value
Worksheets("COD Mapping").Range("p1").Value = Worksheets("HRG Clients ").Range("C9").Value
Worksheets("COD Mapping").Range("r1").Value = Worksheets("HRG Clients ").Range("C10").Value
Worksheets("COD Mapping").Range("t1").Value = Worksheets("HRG Clients ").Range("C11").Value
Worksheets("COD Mapping").Range("v1").Value = Worksheets("HRG Clients ").Range("C12").Value
Worksheets("COD Mapping").Range("x1").Value = Worksheets("HRG Clients ").Range("C13").Value
Worksheets("COD Mapping").Range("z1").Value = Worksheets("HRG Clients ").Range("C14").Value
Worksheets("COD Mapping").Range("ab1").Value = Worksheets("HRG Clients ").Range("C15").Value
Worksheets("COD Mapping").Range("ad1").Value = Worksheets("HRG Clients ").Range("C16").Value
Worksheets("COD Mapping").Range("af1").Value = Worksheets("HRG Clients ").Range("C17").Value
Worksheets("COD Mapping").Range("ah1").Value = Worksheets("HRG Clients ").Range("C18").Value
Worksheets("COD Mapping").Range("aj1").Value = Worksheets("HRG Clients ").Range("C19").Value
Worksheets("COD Mapping").Range("al1").Value = Worksheets("HRG Clients ").Range("C20").Value
Worksheets("COD Mapping").Range("an1").Value = Worksheets("HRG Clients ").Range("C21").Value
Worksheets("COD Mapping").Range("ap1").Value = Worksheets("HRG Clients ").Range("C22").Value
Worksheets("COD Mapping").Range("ar1").Value = Worksheets("HRG Clients ").Range("C23").Value
Worksheets("COD Mapping").Range("at1").Value = Worksheets("HRG Clients ").Range("C24").Value
Worksheets("COD Mapping").Range("av1").Value = Worksheets("HRG Clients ").Range("C25").Value
Worksheets("COD Mapping").Range("ax1").Value = Worksheets("HRG Clients ").Range("C26").Value
Worksheets("COD Mapping").Range("az1").Value = Worksheets("HRG Clients ").Range("C27").Value


End Sub
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Try this

Code:
Sub TransposeValue()
    Dim i As Long, col As Long
    
    Sheets("COD Mapping").Rows("1").ClearContents
    Sheets("COD Mapping").Range("C1").Value = "Client"
    col = 4
    For i = 3 To 27
        Sheets("COD Mapping").Cells(1, col).Value = Sheets("HRG Clients ").Range("C" & i).Value
        col = col + 2
    Next
End Sub
 
Upvote 0
Try this

Code:
Sub TransposeValue()
    Dim i As Long, col As Long
    
    Sheets("COD Mapping").Rows("1").ClearContents
    Sheets("COD Mapping").Range("C1").Value = "Client"
    col = 4
    For i = 3 To 27
        Sheets("COD Mapping").Cells(1, col).Value = Sheets("HRG Clients ").Range("C" & i).Value
        col = col + 2
    Next
End Sub

omg - I'm so happy I could cry!! THANK YOU THANK YOU THANK YOU!
works perfectly!

thank you again!
 
Upvote 0
I'm glad to help you. I appreciate your kind comments.
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,271
Members
452,628
Latest member
dd2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top