T
T
Toster2342019-03-06 09:50:37
Automation
Toster234, 2019-03-06 09:50:37

How to change an Excel macro from "vertical" to "horizontal"?

There is a macro that selects columns 1 and 3, substituting quotes at the beginning and end of the selected cells.

Sub QQ()
For I = 1 To Cells(Rows.Count, 1).End(xlUp).Row
With Cells(I, 1)
If .Value <> "" And Left(.Value, 1) <> """" And Right(.Value, 1) <> """" Then .Value = """" & .Value & """"
End With
Next I

For I = 1 To Cells(Rows.Count, 1).End(xlUp).Row
With Cells(I, 3)
If .Value <> "" And Left(.Value, 1) <> """" And Right(.Value, 1) <> """" Then .Value = """" & .Value & """"
End With
Next I

End Sub

You need to do the same, only for rows, not for columns.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Bcoon, 2019-03-06
@Toster234

Sub QQQ()
For I = 1 To Cells(1, Columns.Count).End(xlToLeft).Column
With Cells(1, I)
If .Value <> "" And Left(.Value, 1) <> """" And Right(.Value, 1) <> """" Then .Value = """" & .Value & """"
End With
Next I

For I = 1 To Cells(3, Columns.Count).End(xlToLeft).Column
With Cells(3, I)
If .Value <> "" And Left(.Value, 1) <> """" And Right(.Value, 1) <> """" Then .Value = """" & .Value & """"
End With
Next I

End Sub

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question