Add Transpose to line of code

pwill

Active Member
Joined
Nov 22, 2015
Messages
406
Hi can anyone help?

I want to add transpose to the line in red, is there a way to do this?

Code:
Private Sub CommandButton3_Click()

    Set FromSht = Sheets("Sheet1")
    Set ToSht = Sheets("Sheet2")
    
    r = 2
    
    While FromSht.Cells(r, "A") <> "" And FromSht.Cells(r, "C") <> ""
        
    r = r + 1
    
    Wend
    
    If FromSht.Cells(r, "A") <> "" Then
        
    FromSht.Cells(r, "C") = 1
        
    FromSht.Range("A" & r & ":B" & r).[COLOR=#ff0000]Copy ToSht.Range("AK20:AL20")[/COLOR]
    
    End If

End Sub

I would like the copy to transpose to AK20:AK21


Any help would be apprieciated

Regards

pwill
 
Last edited:

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Hello,

does this work as expected?

Code:
Private Sub CommandButton3_Click()

    Set FromSht = Sheets("Sheet1")
    Set ToSht = Sheets("Sheet2")
    
    r = 2
    
    While FromSht.Cells(r, "A") <> "" And FromSht.Cells(r, "C") <> ""
        
    r = r + 1
    
    Wend
    
    If FromSht.Cells(r, "A") <> "" Then
        
    FromSht.Cells(r, "C") = 1
    
    FromSht.Range("A" & r & ":B" & r).Copy
    ToSht.Range("AK20").PasteSpecial (xlPasteAll), Transpose:=True
    
    End If

End Sub
 
Upvote 0
Hello,

does this work as expected?

Code:
Private Sub CommandButton3_Click()

    Set FromSht = Sheets("Sheet1")
    Set ToSht = Sheets("Sheet2")
    
    r = 2
    
    While FromSht.Cells(r, "A") <> "" And FromSht.Cells(r, "C") <> ""
        
    r = r + 1
    
    Wend
    
    If FromSht.Cells(r, "A") <> "" Then
        
    FromSht.Cells(r, "C") = 1
    
    FromSht.Range("A" & r & ":B" & r).Copy
    ToSht.Range("AK20").PasteSpecial (xlPasteAll), Transpose:=True
    
    End If

End Sub



Hi onlyadrafter, yes thats works,

thanks for your help, much apprieciated

pwill
 
Upvote 0

Forum statistics

Threads
1,216,574
Messages
6,131,499
Members
449,653
Latest member
aurelius33

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