PC Review


Reply
 
 
MCheru
Guest
Posts: n/a
 
      8th Apr 2009
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. I’ve 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 With Quote
 
 
 
 
Gary''s Student
Guest
Posts: n/a
 
      8th Apr 2009
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. I’ve 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 With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      8th Apr 2009
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" <(E-Mail Removed)> wrote in message
news:571730A3-5476-4B05-AAFD-(E-Mail Removed)...
>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. I’ve 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 With Quote
 
MCheru
Guest
Posts: n/a
 
      8th Apr 2009
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. I’ve 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 With Quote
 
MCheru
Guest
Posts: n/a
 
      8th Apr 2009
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" <(E-Mail Removed)> wrote in message
> news:571730A3-5476-4B05-AAFD-(E-Mail Removed)...
> >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. I’ve 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 With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      9th Apr 2009
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" <(E-Mail Removed)> wrote in message
newsBF680A0-08EA-46E1-822E-(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
>> news:571730A3-5476-4B05-AAFD-(E-Mail Removed)...
>> >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. I’ve 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 With Quote
 
MCheru
Guest
Posts: n/a
 
      10th Apr 2009
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" <(E-Mail Removed)> wrote in message
> newsBF680A0-08EA-46E1-822E-(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> >> news:571730A3-5476-4B05-AAFD-(E-Mail Removed)...
> >> >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. I’ve 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
http://LongPathTool.com - find and delete/copy path too long filesfrom your hard drive or LAN Windows tool to copy or delete files and folderswith path too long or filename too long error. Just browse to the file andpress a button to copy or d Martin Krag Windows XP Internet Explorer 0 22nd Apr 2011 10:08 AM
http://LongPathTool.com - find and delete/copy path too long filesfrom your hard drive or LAN Windows tool to copy or delete files and folderswith path too long or filename too long error. Just browse to the file andpress a button to copy or d Martin Krag Windows XP Configuration 0 22nd Apr 2011 10:05 AM
Copy local users and groups, copy shares with security, copy homeuser folders usenet@sphere10.com Microsoft Windows 2000 Active Directory 1 17th Feb 2009 01:31 PM
Copy local users and groups, copy shares with security, copy homeuser folders usenet@sphere10.com Windows Vista General Discussion 2 17th Feb 2009 01:31 PM
EXCEL FILE a copy/a copy/a copy ....filename =?Utf-8?B?dmU=?= Microsoft Excel New Users 1 29th Sep 2005 09:12 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:17 AM.