Using VBA in Excel I need to find the first column that has an empty or blank cell in the first row of my spreadsheet.
I found this post that covers how to find the first ROW that has an empty or blank cell in a given column. I've tried to use this logic to look for the first empty column in a row but have not been able to do so.
This is how I've tried to adapt the logic from the post I found to get what I want but it doesn't work:
Sheets(targetWorksheet).Range("A1").End(xlToRight).Offset(1, 0).Column
I was able to put this code together which does get me the first column that has an empty or blank cell in the first row but it seems very clunky, there has to be a better way.
Dim blah As String
cellColumns = Array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z")
For x = 0 To 3
blah = Sheets(targetWorksheet).Range(cellColumns(x) + "1").Value
If blah = "" Then
MsgBox (cellColumns(x)) ' cellColumns(x) gives the column letter I'm looking for
Exit For
End If
Next
As always, a correct, clearly explained answer will be marked as the accepted answer and upvoted.
Thanks in advance!