Getting unexpected gaps in a spreadsheet

  • Thread starter christopher ward
  • Start date
C

christopher ward

Hi All

I wonder if I might ask a question. If you take the time to answer I thank
you in advance. I have written some VBA code and am getting blank lines in my
results between the data lines I expect. The snip of code which is in error
is -

If col1 <> "" Then
ActiveWorkbook.Close
Sheets("Data").Select
Lastrowdata = ActiveSheet.UsedRange.Rows.Count

nudge = nudge + 1
Worksheets("Data").Cells(Lastrowdata + nudge, 1).Value =
col1

Workbooks.Open Filename:=sPath & sFile
End If

The sheet data ends up looking like this with the extra gaps -


Finance 1 A
Finance 1 B

Finance 1 C


Finance 1 D



Finance 3 A




Finance 3 B





Finance 3 C






Finance 2 A

Hence lots of gaps which I do not want. How do I get rid of them or detect
the last data row correctly. All my data is in the sheet but I want it row
after row as such.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top