Solved

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

Posted on 2011-03-07
9
284 Views
Last Modified: 2012-05-11
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
Comment
Question by:dmalovich
  • 4
  • 3
  • 2
9 Comments
 
LVL 10

Expert Comment

by:Makrini
ID: 35063331
 Range("E" & Rows.Count).End(xlUp).Offset(1, 0) = "This Was blank"

Open in new window

0
 
LVL 50

Expert Comment

by:teylyn
ID: 35063344
columns, not rows, Makrini

try

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

cheers, teylyn
0
 
LVL 50

Expert Comment

by:teylyn
ID: 35063349
Or get the cell address with

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

Open in new window

0
 
LVL 10

Expert Comment

by:Makrini
ID: 35063352
oops - of course - I read wrong
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:dmalovich
ID: 35063364
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
 
LVL 50

Expert Comment

by:teylyn
ID: 35063395
like

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

Author Comment

by:dmalovich
ID: 35063439
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
 
LVL 50

Accepted Solution

by:
teylyn earned 500 total points
ID: 35063452
I'll try again. Maybe I have invisible ink :)

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

Author Closing Comment

by:dmalovich
ID: 35063470
Awesome. Thanks.....
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now