Hi I am a beginner in VBA scripting but I am working on a sheet where I want to copy data in one cell to multiple cells in the same row as long as it is not empty but separate the two data by a comma and do this through out the table
Before Macro
[TABLE="width: 256"]
<tbody>[TR]
[TD="width: 64"]A[/TD]
[TD="width: 64"]B[/TD]
[TD="width: 64"]C[/TD]
[TD="width: 64"]D[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 256"]
<tbody>[TR]
[TD="width: 64"]a[/TD]
[TD="width: 64"]d[/TD]
[TD="width: 64"][/TD]
[TD="width: 64"][/TD]
[/TR]
[TR]
[TD]b[/TD]
[TD]d[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]c[/TD]
[TD]d[/TD]
[TD]p[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]d[/TD]
[TD]e[/TD]
[TD]o[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]e[/TD]
[TD]f[/TD]
[TD]g[/TD]
[TD]l[/TD]
[/TR]
[TR]
[TD]f[/TD]
[TD]e[/TD]
[TD]x[/TD]
[TD]f[/TD]
[/TR]
</tbody>[/TABLE]
Here is what I mean: I want the data in Column A (if there is data) to be duplicated through the row separated by a comma and possibly delete column A. I tried to use do-while loop with a formula but my issue is that the sheet is not fixed, meaning the length of rows and columns might vary depending on when the report is generated and I do this task weekly, some help in automating this will be a great help.
After Macro
[TABLE="width: 256"]
<tbody>[TR]
[TD="class: xl65, width: 64"]<s>A</s>[/TD]
[TD="width: 64"]B[/TD]
[TD="width: 64"]C[/TD]
[TD="width: 64"]D[/TD]
[/TR]
[TR]
[TD="class: xl65"]<s>a</s>[/TD]
[TD]a,d[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="class: xl65"]<s>b</s>[/TD]
[TD]b,d[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="class: xl65"]<s>c</s>[/TD]
[TD]c,d[/TD]
[TD]c,p[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="class: xl65"]<s>d</s>[/TD]
[TD]d,e[/TD]
[TD]d,o[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="class: xl65"]<s>e</s>[/TD]
[TD]e,f[/TD]
[TD]e,g[/TD]
[TD]e,l[/TD]
[/TR]
[TR]
[TD="class: xl65"]<s>f</s>[/TD]
[TD]f,e[/TD]
[TD]f,x[/TD]
[TD]f,f[/TD]
[/TR]
</tbody>[/TABLE]
Before Macro
[TABLE="width: 256"]
<tbody>[TR]
[TD="width: 64"]A[/TD]
[TD="width: 64"]B[/TD]
[TD="width: 64"]C[/TD]
[TD="width: 64"]D[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 256"]
<tbody>[TR]
[TD="width: 64"]a[/TD]
[TD="width: 64"]d[/TD]
[TD="width: 64"][/TD]
[TD="width: 64"][/TD]
[/TR]
[TR]
[TD]b[/TD]
[TD]d[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]c[/TD]
[TD]d[/TD]
[TD]p[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]d[/TD]
[TD]e[/TD]
[TD]o[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]e[/TD]
[TD]f[/TD]
[TD]g[/TD]
[TD]l[/TD]
[/TR]
[TR]
[TD]f[/TD]
[TD]e[/TD]
[TD]x[/TD]
[TD]f[/TD]
[/TR]
</tbody>[/TABLE]
Here is what I mean: I want the data in Column A (if there is data) to be duplicated through the row separated by a comma and possibly delete column A. I tried to use do-while loop with a formula but my issue is that the sheet is not fixed, meaning the length of rows and columns might vary depending on when the report is generated and I do this task weekly, some help in automating this will be a great help.
After Macro
[TABLE="width: 256"]
<tbody>[TR]
[TD="class: xl65, width: 64"]<s>A</s>[/TD]
[TD="width: 64"]B[/TD]
[TD="width: 64"]C[/TD]
[TD="width: 64"]D[/TD]
[/TR]
[TR]
[TD="class: xl65"]<s>a</s>[/TD]
[TD]a,d[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="class: xl65"]<s>b</s>[/TD]
[TD]b,d[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="class: xl65"]<s>c</s>[/TD]
[TD]c,d[/TD]
[TD]c,p[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="class: xl65"]<s>d</s>[/TD]
[TD]d,e[/TD]
[TD]d,o[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="class: xl65"]<s>e</s>[/TD]
[TD]e,f[/TD]
[TD]e,g[/TD]
[TD]e,l[/TD]
[/TR]
[TR]
[TD="class: xl65"]<s>f</s>[/TD]
[TD]f,e[/TD]
[TD]f,x[/TD]
[TD]f,f[/TD]
[/TR]
</tbody>[/TABLE]
Last edited: