#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Copy Down

I would like to create a macro that will search every cell in column K. When
a blank cell is found in Column K, I want the macro to copy the contents in
the cell above it and paste those contents in each blank cell in Column K
going down until the next cell with contents is reached. Ive been working
with this code but unsuccessfully. It was originally intended for a range of
columns.

Sub FillBlankRows()
Dim BlankCell As Integer
Dim r As Long
Dim col As Long

For r = 3 To 100
For col = 11 to 11
If Cells(r, col).Value = "" Then
BlankCell = BlankCell + 1
End If
Next
If BlankCell = 11 Then
Range("K" & r - 1 & ":K" & r - 1).Copy Range("K" & r)

End If
BlankCell = 0
Next
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Copy Down

Sub WaitABit()
Dim cel As Range
For Each cel In Range("K:K")
If cel.Value = "" Then
cel.Value = cel.Offset(-1, 0).Value
End If
Next cel
End Sub



K1 must not be empty
--
Gary''s Student - gsnu200844


"MCheru" wrote:

I would like to create a macro that will search every cell in column K. When
a blank cell is found in Column K, I want the macro to copy the contents in
the cell above it and paste those contents in each blank cell in Column K
going down until the next cell with contents is reached. Ive been working
with this code but unsuccessfully. It was originally intended for a range of
columns.

Sub FillBlankRows()
Dim BlankCell As Integer
Dim r As Long
Dim col As Long

For r = 3 To 100
For col = 11 to 11
If Cells(r, col).Value = "" Then
BlankCell = BlankCell + 1
End If
Next
If BlankCell = 11 Then
Range("K" & r - 1 & ":K" & r - 1).Copy Range("K" & r)

End If
BlankCell = 0
Next
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Copy Down

Give this a try...

Sub FillBlanksInColumnK()
Dim R As Range
Dim Blanks As Range
Dim LastRow As Long
On Error GoTo Whoops
With Worksheets("Sheet4")
LastRow = .Cells(.Rows.Count, "K").End(xlUp).Row
Set Blanks = .Range("K2:K" & LastRow).SpecialCells(xlCellTypeBlanks)
For Each R In Blanks
R.Value = R.Offset(-1).Value
Next
End With
Exit Sub
Whoops:
MsgBox "There are no blank cells!"
End Sub

--
Rick (MVP - Excel)


"MCheru" wrote in message
...
I would like to create a macro that will search every cell in column K.
When
a blank cell is found in Column K, I want the macro to copy the contents
in
the cell above it and paste those contents in each blank cell in Column K
going down until the next cell with contents is reached. Ive been
working
with this code but unsuccessfully. It was originally intended for a range
of
columns.

Sub FillBlankRows()
Dim BlankCell As Integer
Dim r As Long
Dim col As Long

For r = 3 To 100
For col = 11 to 11
If Cells(r, col).Value = "" Then
BlankCell = BlankCell + 1
End If
Next
If BlankCell = 11 Then
Range("K" & r - 1 & ":K" & r - 1).Copy Range("K" & r)

End If
BlankCell = 0
Next
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Copy Down

Thank you. This works amazing! Could this be modified so that if no
contents are in column J it stops?

"Gary''s Student" wrote:

Sub WaitABit()
Dim cel As Range
For Each cel In Range("K:K")
If cel.Value = "" Then
cel.Value = cel.Offset(-1, 0).Value
End If
Next cel
End Sub



K1 must not be empty
--
Gary''s Student - gsnu200844


"MCheru" wrote:

I would like to create a macro that will search every cell in column K. When
a blank cell is found in Column K, I want the macro to copy the contents in
the cell above it and paste those contents in each blank cell in Column K
going down until the next cell with contents is reached. Ive been working
with this code but unsuccessfully. It was originally intended for a range of
columns.

Sub FillBlankRows()
Dim BlankCell As Integer
Dim r As Long
Dim col As Long

For r = 3 To 100
For col = 11 to 11
If Cells(r, col).Value = "" Then
BlankCell = BlankCell + 1
End If
Next
If BlankCell = 11 Then
Range("K" & r - 1 & ":K" & r - 1).Copy Range("K" & r)

End If
BlankCell = 0
Next
End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Copy Down

Thank you for your help. This is outstanding. Could this be modified so
that if no contents are in column J it stops?

"Rick Rothstein" wrote:

Give this a try...

Sub FillBlanksInColumnK()
Dim R As Range
Dim Blanks As Range
Dim LastRow As Long
On Error GoTo Whoops
With Worksheets("Sheet4")
LastRow = .Cells(.Rows.Count, "K").End(xlUp).Row
Set Blanks = .Range("K2:K" & LastRow).SpecialCells(xlCellTypeBlanks)
For Each R In Blanks
R.Value = R.Offset(-1).Value
Next
End With
Exit Sub
Whoops:
MsgBox "There are no blank cells!"
End Sub

--
Rick (MVP - Excel)


"MCheru" wrote in message
...
I would like to create a macro that will search every cell in column K.
When
a blank cell is found in Column K, I want the macro to copy the contents
in
the cell above it and paste those contents in each blank cell in Column K
going down until the next cell with contents is reached. Ive been
working
with this code but unsuccessfully. It was originally intended for a range
of
columns.

Sub FillBlankRows()
Dim BlankCell As Integer
Dim r As Long
Dim col As Long

For r = 3 To 100
For col = 11 to 11
If Cells(r, col).Value = "" Then
BlankCell = BlankCell + 1
End If
Next
If BlankCell = 11 Then
Range("K" & r - 1 & ":K" & r - 1).Copy Range("K" & r)

End If
BlankCell = 0
Next
End Sub





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Copy Down

Does this do what you want?

Sub FillBlanksInColumnK()
Dim R As Range
Dim Blanks As Range
Dim LastRow As Long
On Error GoTo Whoops
With Worksheets("Sheet4")
LastRow = .Cells(.Rows.Count, "J").End(xlUp).Row
Set Blanks = .Range("K2:K" & LastRow).SpecialCells(xlCellTypeBlanks)
For Each R In Blanks
R.Value = R.Offset(-1).Value
Next
End With
Exit Sub
Whoops:
MsgBox "There are no blank cells!"
End Sub

--
Rick (MVP - Excel)


"MCheru" wrote in message
...
Thank you for your help. This is outstanding. Could this be modified so
that if no contents are in column J it stops?

"Rick Rothstein" wrote:

Give this a try...

Sub FillBlanksInColumnK()
Dim R As Range
Dim Blanks As Range
Dim LastRow As Long
On Error GoTo Whoops
With Worksheets("Sheet4")
LastRow = .Cells(.Rows.Count, "K").End(xlUp).Row
Set Blanks = .Range("K2:K" & LastRow).SpecialCells(xlCellTypeBlanks)
For Each R In Blanks
R.Value = R.Offset(-1).Value
Next
End With
Exit Sub
Whoops:
MsgBox "There are no blank cells!"
End Sub

--
Rick (MVP - Excel)


"MCheru" wrote in message
...
I would like to create a macro that will search every cell in column K.
When
a blank cell is found in Column K, I want the macro to copy the
contents
in
the cell above it and paste those contents in each blank cell in Column
K
going down until the next cell with contents is reached. Ive been
working
with this code but unsuccessfully. It was originally intended for a
range
of
columns.

Sub FillBlankRows()
Dim BlankCell As Integer
Dim r As Long
Dim col As Long

For r = 3 To 100
For col = 11 to 11
If Cells(r, col).Value = "" Then
BlankCell = BlankCell + 1
End If
Next
If BlankCell = 11 Then
Range("K" & r - 1 & ":K" & r - 1).Copy Range("K" & r)

End If
BlankCell = 0
Next
End Sub




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Copy Down

Wow, this is exactly what I was looking for. Thank you so very very much.

"Rick Rothstein" wrote:

Does this do what you want?

Sub FillBlanksInColumnK()
Dim R As Range
Dim Blanks As Range
Dim LastRow As Long
On Error GoTo Whoops
With Worksheets("Sheet4")
LastRow = .Cells(.Rows.Count, "J").End(xlUp).Row
Set Blanks = .Range("K2:K" & LastRow).SpecialCells(xlCellTypeBlanks)
For Each R In Blanks
R.Value = R.Offset(-1).Value
Next
End With
Exit Sub
Whoops:
MsgBox "There are no blank cells!"
End Sub

--
Rick (MVP - Excel)


"MCheru" wrote in message
...
Thank you for your help. This is outstanding. Could this be modified so
that if no contents are in column J it stops?

"Rick Rothstein" wrote:

Give this a try...

Sub FillBlanksInColumnK()
Dim R As Range
Dim Blanks As Range
Dim LastRow As Long
On Error GoTo Whoops
With Worksheets("Sheet4")
LastRow = .Cells(.Rows.Count, "K").End(xlUp).Row
Set Blanks = .Range("K2:K" & LastRow).SpecialCells(xlCellTypeBlanks)
For Each R In Blanks
R.Value = R.Offset(-1).Value
Next
End With
Exit Sub
Whoops:
MsgBox "There are no blank cells!"
End Sub

--
Rick (MVP - Excel)


"MCheru" wrote in message
...
I would like to create a macro that will search every cell in column K.
When
a blank cell is found in Column K, I want the macro to copy the
contents
in
the cell above it and paste those contents in each blank cell in Column
K
going down until the next cell with contents is reached. Ive been
working
with this code but unsuccessfully. It was originally intended for a
range
of
columns.

Sub FillBlankRows()
Dim BlankCell As Integer
Dim r As Long
Dim col As Long

For r = 3 To 100
For col = 11 to 11
If Cells(r, col).Value = "" Then
BlankCell = BlankCell + 1
End If
Next
If BlankCell = 11 Then
Range("K" & r - 1 & ":K" & r - 1).Copy Range("K" & r)

End If
BlankCell = 0
Next
End Sub





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
Copy/Paste how to avoid the copy of formula cells w/o calc values Dennis Excel Discussion (Misc queries) 10 March 2nd 06 10:47 PM
copy formulas from a contiguous range to a safe place and copy them back later Lucas Budlong Excel Programming 2 February 22nd 06 08:26 PM
EXCEL FILE a copy/a copy/a copy ....filename ve New Users to Excel 1 September 29th 05 09:12 PM
Code to copy range vs Copy Entire Worksheet - can't figure it out Mike Taylor Excel Programming 1 April 15th 04 08:34 PM
How copy format, font, color and border without copy/paste? Michel[_3_] Excel Programming 1 November 5th 03 04:43 PM


All times are GMT +1. The time now is 05:45 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"