ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Getting unexpected gaps in a spreadsheet (https://www.excelbanter.com/excel-programming/427990-getting-unexpected-gaps-spreadsheet.html)

christopher ward

Getting unexpected gaps in a spreadsheet
 
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.

--
C Ward

christopher ward

Getting unexpected gaps in a spreadsheet
 
Not to worry I fixed it - many thanks
--
C Ward


"christopher ward" wrote:

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.

--
C Ward



All times are GMT +1. The time now is 02:57 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com