Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Find Blank Line

I have a spreadsheet that is being populated by external data. The data is
grouped together by company and between each company there are a couple of
blank lines to allow for the insertion of some code. I am looking for a way
to find the first blank line so I can add the formulas using code and then
once hte formulas are added move onto the next group etc. Can anyone help me
with this

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Find Blank Line

I like to pick out a column that always has data in it if that row is used:

Dim NextRow as long
with worksheets("Sheet999")
Nextrow = .cells(.rows.count,"X").end(xlup).row + 1

.cells(nextrow,"A").value = "Used to be empty!!"

end with



Nigel wrote:

I have a spreadsheet that is being populated by external data. The data is
grouped together by company and between each company there are a couple of
blank lines to allow for the insertion of some code. I am looking for a way
to find the first blank line so I can add the formulas using code and then
once hte formulas are added move onto the next group etc. Can anyone help me
with this

Thanks


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Find Blank Line

If you have gaps in your data, maybe you can start at the top and work down:

Nextrow = .cells(1,"X").end(xldown).row + 1

I don't know what "move on" means.

If you mean find the next row, then just do it again.

Nigel wrote:

Ok that one went to the very end of the data, I need it to find the first
blank line enter the expression and then move on

"Dave Peterson" wrote:

I like to pick out a column that always has data in it if that row is used:

Dim NextRow as long
with worksheets("Sheet999")
Nextrow = .cells(.rows.count,"X").end(xlup).row + 1

.cells(nextrow,"A").value = "Used to be empty!!"

end with



Nigel wrote:

I have a spreadsheet that is being populated by external data. The data is
grouped together by company and between each company there are a couple of
blank lines to allow for the insertion of some code. I am looking for a way
to find the first blank line so I can add the formulas using code and then
once hte formulas are added move onto the next group etc. Can anyone help me
with this

Thanks


--

Dave Peterson


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Find Blank Line

I'd use the first suggestion (change "X" to "H")

Dim NextRow as long
with worksheets("Sheet999")
Nextrow = .cells(.rows.count,"H").end(xlup).row + 1
.cells(nextrow,"I").value = "Used to be empty!!"
end with

You can use the same technique to find the next empty row--or you could just add
one after you fill that cell:

nextrow = nextrow + 1

Either should work.

Nigel wrote:

This may be a better example

My data starts in Row

THere are 5 rows of data for the customer then 2 blank rows then another
customers data will begin

I am looking for something that will search row H anf find the first blank
line and then enter an expression in cell I in the blank row.

Once that expression is entered it needs to loop and find the next blank
line and so on

thanks
"Dave Peterson" wrote:

If you have gaps in your data, maybe you can start at the top and work down:

Nextrow = .cells(1,"X").end(xldown).row + 1

I don't know what "move on" means.

If you mean find the next row, then just do it again.

Nigel wrote:

Ok that one went to the very end of the data, I need it to find the first
blank line enter the expression and then move on

"Dave Peterson" wrote:

I like to pick out a column that always has data in it if that row is used:

Dim NextRow as long
with worksheets("Sheet999")
Nextrow = .cells(.rows.count,"X").end(xlup).row + 1

.cells(nextrow,"A").value = "Used to be empty!!"

end with



Nigel wrote:

I have a spreadsheet that is being populated by external data. The data is
grouped together by company and between each company there are a couple of
blank lines to allow for the insertion of some code. I am looking for a way
to find the first blank line so I can add the formulas using code and then
once hte formulas are added move onto the next group etc. Can anyone help me
with this

Thanks

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Find Blank Line

You can loop through those cells if you want. But are you sure you want to loop
through all 64k (or 1Meg) rows?

Dim iRow as long
with activesheet
for irow = 1 to .cells.specialcells(xlcelltypelastcell).row
if .cells(irow,"H").value = "" then
'put something in that cell
end if
next irow
end with

Nigel wrote:

OK I have narrowed this down

Dim NextRow As Long
Set rngB = ActiveSheet.UsedRange.Columns("H:H")
For R = 1 To rngB.Rows.Count
MsgBox ActiveSheet.Cells(R, 8).Value, vbOKOnly
If ActiveSheet.Cells(R, 8).Value Like "" Then
With Worksheets("Sheet3")
NextRow = .Cells(.Rows.Count, "H").End(xlUp).Row + 1

.Cells(NextRow, "I").Value = "Used to be empty!!"
End With
End If
Next R

the value in next wrong is going to the very last row instead of to the
blank row so if there are 53 rows of data and the first blank row is at row
10 the value in nextrow is 54 instead of 10

not sure how to correct that

"Dave Peterson" wrote:

I'd use the first suggestion (change "X" to "H")

Dim NextRow as long
with worksheets("Sheet999")
Nextrow = .cells(.rows.count,"H").end(xlup).row + 1
.cells(nextrow,"I").value = "Used to be empty!!"
end with

You can use the same technique to find the next empty row--or you could just add
one after you fill that cell:

nextrow = nextrow + 1

Either should work.

Nigel wrote:

This may be a better example

My data starts in Row

THere are 5 rows of data for the customer then 2 blank rows then another
customers data will begin

I am looking for something that will search row H anf find the first blank
line and then enter an expression in cell I in the blank row.

Once that expression is entered it needs to loop and find the next blank
line and so on

thanks
"Dave Peterson" wrote:

If you have gaps in your data, maybe you can start at the top and work down:

Nextrow = .cells(1,"X").end(xldown).row + 1

I don't know what "move on" means.

If you mean find the next row, then just do it again.

Nigel wrote:

Ok that one went to the very end of the data, I need it to find the first
blank line enter the expression and then move on

"Dave Peterson" wrote:

I like to pick out a column that always has data in it if that row is used:

Dim NextRow as long
with worksheets("Sheet999")
Nextrow = .cells(.rows.count,"X").end(xlup).row + 1

.cells(nextrow,"A").value = "Used to be empty!!"

end with



Nigel wrote:

I have a spreadsheet that is being populated by external data. The data is
grouped together by company and between each company there are a couple of
blank lines to allow for the insertion of some code. I am looking for a way
to find the first blank line so I can add the formulas using code and then
once hte formulas are added move onto the next group etc. Can anyone help me
with this

Thanks

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Find Blank Line

Dave I actually managed to solve the problem,

I used part of your code and some of mine here was my solution


Dim NextRow As Long
lastrow = ActiveSheet.Cells(Rows.Count, "AH").End(xlUp).Row
Set rngB = ActiveSheet.UsedRange.Columns("AH:AH")

For r = 1 To rngB.Rows.Count

If ActiveSheet.Cells(r, 34).Value = "1" Then

Range("J" & r) = "test"
Range("k" & r) = "test"
Range("l" & r) = "test"
Range("m" & r) = "test"
Range("n" & r) = "test"
Range("o" & r) = "test"
Range("p" & r) = "test"
Range("q" & r) = "test"
End If
If ActiveSheet.Cells(r, 34).Value = "2" Then
Range("J" & r) = "test 2"
Range("k" & r) = "test 2"
Range("l" & r) = "test 2"
Range("m" & r) = "test 2"
Range("n" & r) = "test 2"
Range("o" & r) = "test 2"
Range("p" & r) = "test 2"
Range("q" & r) = "test 2"

End If

Next r


if column 34 I have a calculation that looks to see if the row is blank, if
it is it puts a 1 in the cell if not it puts a 0, it also looks to see if
the value in the previous cell is 1 and if so it puts a 2, this allows me to
add to different formulas in the 2 blank rows

it may seem a little be of a long way of going about it but it appears to be
doing what I wanted.

I really appreciate your help as you managed to push me in the right
direction and put more thought into it

Thanks

Nigel
"Dave Peterson" wrote:

You can loop through those cells if you want. But are you sure you want to loop
through all 64k (or 1Meg) rows?

Dim iRow as long
with activesheet
for irow = 1 to .cells.specialcells(xlcelltypelastcell).row
if .cells(irow,"H").value = "" then
'put something in that cell
end if
next irow
end with

Nigel wrote:

OK I have narrowed this down

Dim NextRow As Long
Set rngB = ActiveSheet.UsedRange.Columns("H:H")
For R = 1 To rngB.Rows.Count
MsgBox ActiveSheet.Cells(R, 8).Value, vbOKOnly
If ActiveSheet.Cells(R, 8).Value Like "" Then
With Worksheets("Sheet3")
NextRow = .Cells(.Rows.Count, "H").End(xlUp).Row + 1

.Cells(NextRow, "I").Value = "Used to be empty!!"
End With
End If
Next R

the value in next wrong is going to the very last row instead of to the
blank row so if there are 53 rows of data and the first blank row is at row
10 the value in nextrow is 54 instead of 10

not sure how to correct that

"Dave Peterson" wrote:

I'd use the first suggestion (change "X" to "H")

Dim NextRow as long
with worksheets("Sheet999")
Nextrow = .cells(.rows.count,"H").end(xlup).row + 1
.cells(nextrow,"I").value = "Used to be empty!!"
end with

You can use the same technique to find the next empty row--or you could just add
one after you fill that cell:

nextrow = nextrow + 1

Either should work.

Nigel wrote:

This may be a better example

My data starts in Row

THere are 5 rows of data for the customer then 2 blank rows then another
customers data will begin

I am looking for something that will search row H anf find the first blank
line and then enter an expression in cell I in the blank row.

Once that expression is entered it needs to loop and find the next blank
line and so on

thanks
"Dave Peterson" wrote:

If you have gaps in your data, maybe you can start at the top and work down:

Nextrow = .cells(1,"X").end(xldown).row + 1

I don't know what "move on" means.

If you mean find the next row, then just do it again.

Nigel wrote:

Ok that one went to the very end of the data, I need it to find the first
blank line enter the expression and then move on

"Dave Peterson" wrote:

I like to pick out a column that always has data in it if that row is used:

Dim NextRow as long
with worksheets("Sheet999")
Nextrow = .cells(.rows.count,"X").end(xlup).row + 1

.cells(nextrow,"A").value = "Used to be empty!!"

end with



Nigel wrote:

I have a spreadsheet that is being populated by external data. The data is
grouped together by company and between each company there are a couple of
blank lines to allow for the insertion of some code. I am looking for a way
to find the first blank line so I can add the formulas using code and then
once hte formulas are added move onto the next group etc. Can anyone help me
with this

Thanks

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson


--

Dave Peterson

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Find Blank Line

I'm glad you found a solution.

Nigel wrote:

Dave I actually managed to solve the problem,

I used part of your code and some of mine here was my solution

Dim NextRow As Long
lastrow = ActiveSheet.Cells(Rows.Count, "AH").End(xlUp).Row
Set rngB = ActiveSheet.UsedRange.Columns("AH:AH")

For r = 1 To rngB.Rows.Count

If ActiveSheet.Cells(r, 34).Value = "1" Then

Range("J" & r) = "test"
Range("k" & r) = "test"
Range("l" & r) = "test"
Range("m" & r) = "test"
Range("n" & r) = "test"
Range("o" & r) = "test"
Range("p" & r) = "test"
Range("q" & r) = "test"
End If
If ActiveSheet.Cells(r, 34).Value = "2" Then
Range("J" & r) = "test 2"
Range("k" & r) = "test 2"
Range("l" & r) = "test 2"
Range("m" & r) = "test 2"
Range("n" & r) = "test 2"
Range("o" & r) = "test 2"
Range("p" & r) = "test 2"
Range("q" & r) = "test 2"

End If

Next r

if column 34 I have a calculation that looks to see if the row is blank, if
it is it puts a 1 in the cell if not it puts a 0, it also looks to see if
the value in the previous cell is 1 and if so it puts a 2, this allows me to
add to different formulas in the 2 blank rows

it may seem a little be of a long way of going about it but it appears to be
doing what I wanted.

I really appreciate your help as you managed to push me in the right
direction and put more thought into it

Thanks

Nigel
"Dave Peterson" wrote:

You can loop through those cells if you want. But are you sure you want to loop
through all 64k (or 1Meg) rows?

Dim iRow as long
with activesheet
for irow = 1 to .cells.specialcells(xlcelltypelastcell).row
if .cells(irow,"H").value = "" then
'put something in that cell
end if
next irow
end with

Nigel wrote:

OK I have narrowed this down

Dim NextRow As Long
Set rngB = ActiveSheet.UsedRange.Columns("H:H")
For R = 1 To rngB.Rows.Count
MsgBox ActiveSheet.Cells(R, 8).Value, vbOKOnly
If ActiveSheet.Cells(R, 8).Value Like "" Then
With Worksheets("Sheet3")
NextRow = .Cells(.Rows.Count, "H").End(xlUp).Row + 1

.Cells(NextRow, "I").Value = "Used to be empty!!"
End With
End If
Next R

the value in next wrong is going to the very last row instead of to the
blank row so if there are 53 rows of data and the first blank row is at row
10 the value in nextrow is 54 instead of 10

not sure how to correct that

"Dave Peterson" wrote:

I'd use the first suggestion (change "X" to "H")

Dim NextRow as long
with worksheets("Sheet999")
Nextrow = .cells(.rows.count,"H").end(xlup).row + 1
.cells(nextrow,"I").value = "Used to be empty!!"
end with

You can use the same technique to find the next empty row--or you could just add
one after you fill that cell:

nextrow = nextrow + 1

Either should work.

Nigel wrote:

This may be a better example

My data starts in Row

THere are 5 rows of data for the customer then 2 blank rows then another
customers data will begin

I am looking for something that will search row H anf find the first blank
line and then enter an expression in cell I in the blank row.

Once that expression is entered it needs to loop and find the next blank
line and so on

thanks
"Dave Peterson" wrote:

If you have gaps in your data, maybe you can start at the top and work down:

Nextrow = .cells(1,"X").end(xldown).row + 1

I don't know what "move on" means.

If you mean find the next row, then just do it again.

Nigel wrote:

Ok that one went to the very end of the data, I need it to find the first
blank line enter the expression and then move on

"Dave Peterson" wrote:

I like to pick out a column that always has data in it if that row is used:

Dim NextRow as long
with worksheets("Sheet999")
Nextrow = .cells(.rows.count,"X").end(xlup).row + 1

.cells(nextrow,"A").value = "Used to be empty!!"

end with



Nigel wrote:

I have a spreadsheet that is being populated by external data. The data is
grouped together by company and between each company there are a couple of
blank lines to allow for the insertion of some code. I am looking for a way
to find the first blank line so I can add the formulas using code and then
once hte formulas are added move onto the next group etc. Can anyone help me
with this

Thanks

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Find Blank Line

You may find this more efficient
Sub valuecells()
r = 2 'you didn't say what r was
If Cells(r, 34) = 2 Then ext = 2
Range(Cells(r, "j"), Cells(r, "q")) = "test " & ext
End Sub

--
Don Guillett
SalesAid Software

"Nigel" wrote in message
...
Dave I actually managed to solve the problem,

I used part of your code and some of mine here was my solution


Dim NextRow As Long
lastrow = ActiveSheet.Cells(Rows.Count, "AH").End(xlUp).Row
Set rngB = ActiveSheet.UsedRange.Columns("AH:AH")

For r = 1 To rngB.Rows.Count

If ActiveSheet.Cells(r, 34).Value = "1" Then

Range("J" & r) = "test"
Range("k" & r) = "test"
Range("l" & r) = "test"
Range("m" & r) = "test"
Range("n" & r) = "test"
Range("o" & r) = "test"
Range("p" & r) = "test"
Range("q" & r) = "test"
End If
If ActiveSheet.Cells(r, 34).Value = "2" Then
Range("J" & r) = "test 2"
Range("k" & r) = "test 2"
Range("l" & r) = "test 2"
Range("m" & r) = "test 2"
Range("n" & r) = "test 2"
Range("o" & r) = "test 2"
Range("p" & r) = "test 2"
Range("q" & r) = "test 2"

End If

Next r


if column 34 I have a calculation that looks to see if the row is blank,
if
it is it puts a 1 in the cell if not it puts a 0, it also looks to see if
the value in the previous cell is 1 and if so it puts a 2, this allows me
to
add to different formulas in the 2 blank rows

it may seem a little be of a long way of going about it but it appears to
be
doing what I wanted.

I really appreciate your help as you managed to push me in the right
direction and put more thought into it

Thanks

Nigel
"Dave Peterson" wrote:

You can loop through those cells if you want. But are you sure you want
to loop
through all 64k (or 1Meg) rows?

Dim iRow as long
with activesheet
for irow = 1 to .cells.specialcells(xlcelltypelastcell).row
if .cells(irow,"H").value = "" then
'put something in that cell
end if
next irow
end with

Nigel wrote:

OK I have narrowed this down

Dim NextRow As Long
Set rngB = ActiveSheet.UsedRange.Columns("H:H")
For R = 1 To rngB.Rows.Count
MsgBox ActiveSheet.Cells(R, 8).Value, vbOKOnly
If ActiveSheet.Cells(R, 8).Value Like "" Then
With Worksheets("Sheet3")
NextRow = .Cells(.Rows.Count, "H").End(xlUp).Row + 1

.Cells(NextRow, "I").Value = "Used to be empty!!"
End With
End If
Next R

the value in next wrong is going to the very last row instead of to the
blank row so if there are 53 rows of data and the first blank row is at
row
10 the value in nextrow is 54 instead of 10

not sure how to correct that

"Dave Peterson" wrote:

I'd use the first suggestion (change "X" to "H")

Dim NextRow as long
with worksheets("Sheet999")
Nextrow = .cells(.rows.count,"H").end(xlup).row + 1
.cells(nextrow,"I").value = "Used to be empty!!"
end with

You can use the same technique to find the next empty row--or you
could just add
one after you fill that cell:

nextrow = nextrow + 1

Either should work.

Nigel wrote:

This may be a better example

My data starts in Row

THere are 5 rows of data for the customer then 2 blank rows then
another
customers data will begin

I am looking for something that will search row H anf find the
first blank
line and then enter an expression in cell I in the blank row.

Once that expression is entered it needs to loop and find the next
blank
line and so on

thanks
"Dave Peterson" wrote:

If you have gaps in your data, maybe you can start at the top and
work down:

Nextrow = .cells(1,"X").end(xldown).row + 1

I don't know what "move on" means.

If you mean find the next row, then just do it again.

Nigel wrote:

Ok that one went to the very end of the data, I need it to find
the first
blank line enter the expression and then move on

"Dave Peterson" wrote:

I like to pick out a column that always has data in it if
that row is used:

Dim NextRow as long
with worksheets("Sheet999")
Nextrow = .cells(.rows.count,"X").end(xlup).row + 1

.cells(nextrow,"A").value = "Used to be empty!!"

end with



Nigel wrote:

I have a spreadsheet that is being populated by external
data. The data is
grouped together by company and between each company there
are a couple of
blank lines to allow for the insertion of some code. I am
looking for a way
to find the first blank line so I can add the formulas
using code and then
once hte formulas are added move onto the next group etc.
Can anyone help me
with this

Thanks

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson


--

Dave Peterson



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find First Non blank cell than find column header and return that value Silver Rose Excel Worksheet Functions 10 April 30th 07 05:56 PM
insert a blank in every second line of a row EliseT Excel Discussion (Misc queries) 6 June 5th 06 01:43 PM
How do you add a blank line automatically after the Subtotal line MVSD Guy Excel Worksheet Functions 0 April 20th 06 01:04 AM
If cell is not blank, then line out row ~C Excel Worksheet Functions 1 January 26th 06 09:59 PM
Next blank line Aaron Howe[_2_] Excel Programming 0 June 30th 05 06:59 PM


All times are GMT +1. The time now is 07:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"