Тёмный
No video :(

Excel VBA Macro: Transpose Rows to Columns (From One Sheet to Another) 

greggowaffles
Подписаться 6 тыс.
Просмотров 11 тыс.
50% 1

Excel VBA Macro: Transpose Rows to Columns (From One Sheet to Another). In this video, we use a nested For Loop to transpose multiple columns on one sheet into rows on another sheet. We create a macro that determines the size of a given range, and then transposed that range to another worksheet. We also go over how to clear the contents from a worksheet with VBA.
Data used in this video:
gsociology.ica...
Code:
Sub transpose_to_another_sheet()
Dim og As Worksheet
Dim ns As Worksheet
Dim count_col As Integer
Dim count_row As Integer
Set og = ThisWorkbook.Sheets(1)
Set ns = ThisWorkbook.Sheets(2)
ns.Cells.ClearContents
og.Activate
count_col = WorksheetFunction.CountA(Range("A1", Range("A1").End(xlToRight)))
count_row = WorksheetFunction.CountA(Range("A1", Range("A1").End(xlDown)))
For i = 1 To count_col
For j = 1 To count_row
ns.Cells(i, j) = og.Cells(j, i).Text
Next j
Next i
ns.Activate
End Sub
#ExcelVBA #ExcelMacro

Опубликовано:

 

20 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 8   
@Jojosmith342
@Jojosmith342 Год назад
Excellent. Thanks millions again Greg for all your hard work and make our lives much easier. Thank you so much for the written code that save me a lot of time to write copy it down from your video. All thumbs up 👍even before your class starts in case I forget. You're genius. BEST CODER !! 👏
@asaduzzamandaria8731
@asaduzzamandaria8731 2 года назад
Thank you very much.
@greggowaffles
@greggowaffles 2 года назад
No problem! Thank you for watching
@ninabonita8
@ninabonita8 Год назад
Hello, do you help with questions via email? I have a daily file that needs to be added into a weekly file, then the weekly into a monthly. Each daily file has 3 tabs (1st shift, 2nd shift and 3rd shift)..its not like a raw file with headers in row 1 its more of a template and I just cannot figure out how to roll this out into VBA. Can you please help me?
@pattydudow4206
@pattydudow4206 2 года назад
can the raw data in column a be entered in the transposed data sheet as a string in cell A1? example a1 apples a2 bananas to cell a1 with quotes and commas "apples", "bananas"
@abbyfranzia6471
@abbyfranzia6471 2 года назад
Hi, how about Columns to Rows? Thank you
@caturdwiwaluyo4414
@caturdwiwaluyo4414 2 года назад
CAN I MAKE THIS MACRO WITH MACRO RECORDING
@greggowaffles
@greggowaffles 2 года назад
im not sure that you can create loops in a macro recording, but i just added the code from this video in the description for you. hope it helps!!
Далее
Quickly and Easily Transpose Data with Excel VBA
18:18
Putin Əliyevdən nə istəyib? | Rəhim Qazıyev
05:32
The Ultimate Guide to Copying Data using Excel VBA
31:05
Highlight Active Row & Column in Excel (7 Levels)
22:56
How to get the Last Row in VBA(The Right Way!)
15:41
Просмотров 156 тыс.
Putin Əliyevdən nə istəyib? | Rəhim Qazıyev
05:32