Export query result to excel with column width and some more changes...VBA?

Almost never should you actually deploy code written by the macro recorder, unchanged. It relies on Select, Selection, Active, and Activate.
 
I did manage to get it done with this:

Code:
LR = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
i = 1

Do While i <= LR

If Cells(i, 13).Value = "FALSE" Then
ws.Rows(i).EntireRow.Interior.Color = RGB(255, 0, 0)
End If

i = i + 1

Loop

ws.Columns(13).Delete

MsgBox "S&R finished", vbInformation + vbOKOnly, "S&R finished"

13-th was the TRUE/FALSE column that gets deleted at the end. I still have to figure out how to color first 12 columns (now the entire row gets colored). It gets the job done, but having a bit more control over it would be great.
 
Great progress! Glad to hear it.

Maybe adjust one line like:
ws.cells(i,2).Interior.Color = RGB(255, 0, 0)

...(if you wanted to only color the cell in column B)
 

Users who are viewing this thread

Back
Top Bottom