Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Code won't fill to last row in table

Hello-

I have a code to fill all blanks in column F with an "X". There is
data in Columns A:E down to row 2145, but the code only puts the X
down to row 2135. Cell 2136 is the last filled cell in column F, this
has something to do with it. I want the code to search column F based
on the entire range of column E, in this case E2:E2145.

Sub b()

Dim lngLastRow As Long

Application.ScreenUpdating = False

For lngLastRow = Cells(Cells.Rows.Count, "F").End(xlUp).Row To 2
Step -1
If Cells(lngLastRow, "F") = "" Then
Cells(lngLastRow, "F").Value = "X"
End If
Next lngLastRow

Application.ScreenUpdating = True


End Sub

Please help if possible
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Code won't fill to last row in table

Hi

Your code has to look at column E, when it determine last row:

For lngLastRow = Cells(Cells.Rows.Count, "E").End(xlUp).Row To 2 Step -1

It can also be done with this one line:

Sub FillX()
Range("F2", Range("F" &
Rows.Count).End(xlUp)).SpecialCells(xlCellTypeBlan ks) = "X"
End Sub

Regards,
Per

"Sabosis" skrev i meddelelsen
...
Hello-

I have a code to fill all blanks in column F with an "X". There is
data in Columns A:E down to row 2145, but the code only puts the X
down to row 2135. Cell 2136 is the last filled cell in column F, this
has something to do with it. I want the code to search column F based
on the entire range of column E, in this case E2:E2145.

Sub b()

Dim lngLastRow As Long

Application.ScreenUpdating = False

For lngLastRow = Cells(Cells.Rows.Count, "F").End(xlUp).Row To 2
Step -1
If Cells(lngLastRow, "F") = "" Then
Cells(lngLastRow, "F").Value = "X"
End If
Next lngLastRow

Application.ScreenUpdating = True


End Sub

Please help if possible


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Code won't fill to last row in table

Then change the "F" in your in the For statement to "E". However, you don't
have to loop to do this; the following should do what you want...

Sub AssignXs()
Range("F2:F" & Cells(Rows.Count, "E").End(xlUp).Row). _
SpecialCells(xlCellTypeBlanks).Value = "X"
End Sub

--
Rick (MVP - Excel)


"Sabosis" wrote in message
...
Hello-

I have a code to fill all blanks in column F with an "X". There is
data in Columns A:E down to row 2145, but the code only puts the X
down to row 2135. Cell 2136 is the last filled cell in column F, this
has something to do with it. I want the code to search column F based
on the entire range of column E, in this case E2:E2145.

Sub b()

Dim lngLastRow As Long

Application.ScreenUpdating = False

For lngLastRow = Cells(Cells.Rows.Count, "F").End(xlUp).Row To 2
Step -1
If Cells(lngLastRow, "F") = "" Then
Cells(lngLastRow, "F").Value = "X"
End If
Next lngLastRow

Application.ScreenUpdating = True


End Sub

Please help if possible


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Code won't fill to last row in table

That will do what the OP's code does... but it is using the wrong "last
row"... the OP wants the last row in Column E to be applied to Column F's
range.

--
Rick (MVP - Excel)


"Per Jessen" wrote in message
...
Hi

Your code has to look at column E, when it determine last row:

For lngLastRow = Cells(Cells.Rows.Count, "E").End(xlUp).Row To 2 Step -1

It can also be done with this one line:

Sub FillX()
Range("F2", Range("F" &
Rows.Count).End(xlUp)).SpecialCells(xlCellTypeBlan ks) = "X"
End Sub

Regards,
Per

"Sabosis" skrev i meddelelsen
...
Hello-

I have a code to fill all blanks in column F with an "X". There is
data in Columns A:E down to row 2145, but the code only puts the X
down to row 2135. Cell 2136 is the last filled cell in column F, this
has something to do with it. I want the code to search column F based
on the entire range of column E, in this case E2:E2145.

Sub b()

Dim lngLastRow As Long

Application.ScreenUpdating = False

For lngLastRow = Cells(Cells.Rows.Count, "F").End(xlUp).Row To 2
Step -1
If Cells(lngLastRow, "F") = "" Then
Cells(lngLastRow, "F").Value = "X"
End If
Next lngLastRow

Application.ScreenUpdating = True


End Sub

Please help if possible



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Code won't fill to last row in table

You are absolutely right.... Obviously I wasn't alert, when I changed it to
a single line statement....

--
Per

"Rick Rothstein" skrev i meddelelsen
...
That will do what the OP's code does... but it is using the wrong "last
row"... the OP wants the last row in Column E to be applied to Column F's
range.

--
Rick (MVP - Excel)


"Per Jessen" wrote in message
...
Hi

Your code has to look at column E, when it determine last row:

For lngLastRow = Cells(Cells.Rows.Count, "E").End(xlUp).Row To 2 Step -1

It can also be done with this one line:

Sub FillX()
Range("F2", Range("F" &
Rows.Count).End(xlUp)).SpecialCells(xlCellTypeBlan ks) = "X"
End Sub

Regards,
Per

"Sabosis" skrev i meddelelsen
...
Hello-

I have a code to fill all blanks in column F with an "X". There is
data in Columns A:E down to row 2145, but the code only puts the X
down to row 2135. Cell 2136 is the last filled cell in column F, this
has something to do with it. I want the code to search column F based
on the entire range of column E, in this case E2:E2145.

Sub b()

Dim lngLastRow As Long

Application.ScreenUpdating = False

For lngLastRow = Cells(Cells.Rows.Count, "F").End(xlUp).Row To 2
Step -1
If Cells(lngLastRow, "F") = "" Then
Cells(lngLastRow, "F").Value = "X"
End If
Next lngLastRow

Application.ScreenUpdating = True


End Sub

Please help if possible




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
VBA code to fill down Secret Squirrel Excel Discussion (Misc queries) 6 May 23rd 08 05:48 PM
macro code for XML Fill born2achieve Excel Programming 4 January 18th 08 03:20 AM
sub won't fill down via code SLP Excel Programming 3 November 2nd 07 05:38 PM
List Fill Code Cody Excel Programming 5 August 2nd 05 05:19 PM
VBA Code for a pivot table to open database and to reference table current page Pete Straman Straman via OfficeKB.com Excel Programming 0 February 21st 05 03:57 AM


All times are GMT +1. The time now is 05:41 PM.

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

About Us

"It's about Microsoft Excel"