• Status: Solved
• Priority: Medium
• Security: Public
• Views: 303

# I'm trying to find the first empty cell in a row in excel using vba

I have dynamically generated data add to row 7.  For example if I have data in columns A,B,C,D of row 7 how can I find out that E7 is the next empty cell in the row?
0
dmalovich
• 4
• 3
• 2
1 Solution

Commented:
`````` Range("E" & Rows.Count).End(xlUp).Offset(1, 0) = "This Was blank"
``````
0

Microsoft MVP ExcelCommented:
columns, not rows, Makrini

try

Cells(7, Columns.Count).End(xlToLeft).Offset(0, 1) = "This was blank"

cheers, teylyn
0

Microsoft MVP ExcelCommented:
Or get the cell address with

``````MsgBox Cells(7, Columns.Count).End(xlToLeft).Offset(0, 1).Address
``````
0

Commented:
oops - of course - I read wrong
0

Author Commented:
I tried it and when I try to add data to the row it adds it in column E.  What I'm looking for is to return a number that represents the next empty cell.  Example if A,B,C have data how can I return the number 4 because I want to enter data in to column D ( D representing the 4th column).  During the next
iteration I want to put data into E representing the 5th column.  I hope I'm explaining it enough.  Let me know if you have any questions and thanks for responding so quickly.
0

Microsoft MVP ExcelCommented:
like

MsgBox Cells(7, Columns.Count).End(xlToLeft).Offset(0, 1).Column
0

Author Commented:
If I have something in A7,B7,C7,D7 and I want to put something in E7 I would like to find out how to return the number 5 representing the 5th column of row 7.

num = Worksheets("Rank").Cells(7, Columns.Count).End(xlToLeft).Offset(0, 1) returns 0.  How can I return 5 for example to represent E7?
0

Microsoft MVP ExcelCommented:
I'll try again. Maybe I have invisible ink :)

num = Worksheets("Rank").Cells(7, Columns.Count).End(xlToLeft).Offset(0, 1).Column
0

Author Commented:
Awesome. Thanks.....
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

## Featured Post

• 4
• 3
• 2
Tackle projects and never again get stuck behind a technical roadblock.