This Code Runs but nothing happens.

dccp8002

New Member
Joined
Oct 13, 2020
Messages
4
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
The image below shows all the table records on the left, Cells B - F are the column headers and each red number is the rank.
I recorded a macro that selected rank 1 and transposed it into the table in B-F row 1.

I attempted to write this macro to loop through the column(A) with the records:
Excel_table_macro.jpg

VBA Code:
Sub Transpose_data()
'
' Transpose_Data Macro
' transpose the data from one many rows in column to rows in table
Dim Cll As Range
Dim Rng As Range
Dim Rng2 As Range
Set Rng2 = Range("A:A")
Set Rng = Range (Cells(1,1), Cells(1,6))
For Each Cll In Rng2
If IsNumeric(Rng2.Value) Then
Rng.Select
Selection.Copy
Range("B2").End(xlDown).Offset(1,0).Select
Selection.PasteSpecial Paste:=xlPasteALL, Operation:=xlNone, SkipBlanks:=_False, Transpose:=True
End If
Next Cll
End Sub

Thoughts? Any help is much appreciated.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
if you can, the first line of code should also ensure you select the correct sheet
 
Upvote 0
How about
VBA Code:
Sub dccp()
   Dim i As Long
   
   For i = 1 To Range("A" & Rows.Count).End(xlUp).Row Step 6
      Range("B" & Rows.Count).End(xlUp).Offset(1).Resize(, 6).Value = Application.Transpose(Range("A" & i).Resize(6).Value)
   Next i
End Sub
 
Upvote 0
How about
VBA Code:
Sub dccp()
   Dim i As Long
  
   For i = 1 To Range("A" & Rows.Count).End(xlUp).Row Step 6
      Range("B" & Rows.Count).End(xlUp).Offset(1).Resize(, 6).Value = Application.Transpose(Range("A" & i).Resize(6).Value)
   Next i
End Sub
Fluff,

There was a problem with this line:
"For i = 1 To Range("A" & Rows.Count).End(x1Up).Row Step 6"

it threw a Run-time error '1004':
Application - defined or object-defined error
 
Upvote 0
You have missed typed the code, it should be xlUp (lowercase L) not x1Up
 
Upvote 0
How about
VBA Code:
Sub dccp()
   Dim i As Long
  
   For i = 1 To Range("A" & Rows.Count).End(xlUp).Row Step 6
      Range("B" & Rows.Count).End(xlUp).Offset(1).Resize(, 6).Value = Application.Transpose(Range("A" & i).Resize(6).Value)
   Next i
End Sub

This worked! Thank you for the help!
Always remember the "lowercase l" in xlUp and not a "1".
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,650
Messages
6,120,736
Members
448,988
Latest member
BB_Unlv

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