Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Fill blank cells


I am in need of some help. I am new to VBA programming and in need to
find a way to copy a value from column D and paste it in column E in
the blank cells between two values in the column. I am also trying to
delete columns 5 & 6 after I copy and paste the values. The row
deletion works by itself, the trouble is pasting in the blanks cells.
Here is the code I have - what am I doing wrong?

Code:
--------------------

Sub Delete_Empty_Rows()
Dim i As Long
Dim c As Range
Dim rSearchRange As Range
For i = rSearchRange.Row.Count To 1 Step -1
Set c = Worksheets("VALUES").UsedRange.Columns(4).Find("So rt Program:", LookIn:=xlValues)
If WorksheetFunction.CountIf(c) Then
c.SpecialCells(xlCellTypeConstants).Copy
If WorksheetFunction.CountBlank(c) Then
c.SpecialCells(xlCellTypeConstants).PasteSpecial
Next i

Set rSearchRange = Worksheets("VALUES").UsedRange.Columns(6) 'for example
If WorksheetFunction.CountBlank(rSearchRange) Then _
rSearchRange.SpecialCells(xlCellTypeBlanks).Entire Row.Delete
Set rSearchRange = Worksheets("VALUES").UsedRange.Columns(5) 'for example
If WorksheetFunction.CountBlank(rSearchRange) Then _
rSearchRange.SpecialCells(xlCellTypeBlanks).Entire Row.Delete
End Sub

--------------------


--
3Sixty
------------------------------------------------------------------------
3Sixty's Profile: http://www.excelforum.com/member.php...o&userid=28601
View this thread: http://www.excelforum.com/showthread...hreadid=482652

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default Fill blank cells

I haven't worked through all the code but you seem to be refering to the
range rSearchRange before you set it to anything:

Sub Delete_Empty_Rows()
Dim i As Long
Dim c As Range
Dim rSearchRange As Range
For i = rSearchRange.Row.Count To 1 Step -1
...

Hope this helps
Rowan

3Sixty wrote:
I am in need of some help. I am new to VBA programming and in need to
find a way to copy a value from column D and paste it in column E in
the blank cells between two values in the column. I am also trying to
delete columns 5 & 6 after I copy and paste the values. The row
deletion works by itself, the trouble is pasting in the blanks cells.
Here is the code I have - what am I doing wrong?

Code:
--------------------

Sub Delete_Empty_Rows()
Dim i As Long
Dim c As Range
Dim rSearchRange As Range
For i = rSearchRange.Row.Count To 1 Step -1
Set c = Worksheets("VALUES").UsedRange.Columns(4).Find("So rt Program:", LookIn:=xlValues)
If WorksheetFunction.CountIf(c) Then
c.SpecialCells(xlCellTypeConstants).Copy
If WorksheetFunction.CountBlank(c) Then
c.SpecialCells(xlCellTypeConstants).PasteSpecial
Next i

Set rSearchRange = Worksheets("VALUES").UsedRange.Columns(6) 'for example
If WorksheetFunction.CountBlank(rSearchRange) Then _
rSearchRange.SpecialCells(xlCellTypeBlanks).Entire Row.Delete
Set rSearchRange = Worksheets("VALUES").UsedRange.Columns(5) 'for example
If WorksheetFunction.CountBlank(rSearchRange) Then _
rSearchRange.SpecialCells(xlCellTypeBlanks).Entire Row.Delete
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
Fill blank cells with an if formula? Gaby Excel Worksheet Functions 1 September 17th 07 04:26 PM
Fill in blank cells Ian Excel Discussion (Misc queries) 3 December 15th 06 08:06 AM
FILL IN BLANK CELLS Charles Excel Discussion (Misc queries) 2 August 8th 05 07:07 PM
Fill blank cells jenny Excel Discussion (Misc queries) 2 January 7th 05 02:33 PM
Fill blank cells with 0 Cheri[_2_] Excel Programming 5 December 7th 03 08:45 PM


All times are GMT +1. The time now is 11:16 AM.

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"