Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Fill Blank Cell Not working

I have a macro that is supposed to copy and paste data from one spreadsheet
into another in the same workbook.
I need the blank cells to be filled with a space (" ") if there is not
data in it. I have the macro below.

TIA

The macro works for the data in the ("e40:e43") range, but removes the
pasted data in the ("c40:d43") range. Any ideas??

With ThisWorkbook
Set wksCopy = .Worksheets("Summary")
Set wksPaste = .Worksheets("Plot_Dominant_Rip_Veg")
End With

With Range("c40:d43", Range("c" &
Rows.Count).End(xlUp)).SpecialCells(xlCellTypeBlan ks)
.FormulaR1C1 = "r1c1"
.Value = " "
.Columns("c").MergeCells = False
End With


With Range("e40:F43", Range("e" &
Rows.Count).End(xlUp)).SpecialCells(xlCellTypeBlan ks)
.FormulaR1C1 = "r1c1"
.Value = " "
.Columns("e").MergeCells = False
End With


Set rngCopy = SetCopyRange(wksCopy, "B5:C5")
Set rngPaste = SetPasteRangeByColumn(wksPaste, "A")
rngCopy.Copy rngPaste

Set rngCopy = SetCopyRange(wksCopy, "C40:D43")
Set rngPaste = SetPasteRangeByColumn(wksPaste, "D")
rngCopy.Copy rngPaste

Set rngCopy = SetCopyRange(wksCopy, "E40:F43")
Set rngPaste = SetPasteRangeByColumn(wksPaste, "F")
rngCopy.Copy rngPaste

With Sheets("Plot_Dominant_Rip_Veg")
LastRow = .Cells(.Rows.Count, "f").End(xlUp).Row

'using the last used cell in column A to get the row to copy
Set RngToCopy = .Cells(.Rows.Count, "A").End(xlUp)

HowManyRows = LastRow - RngToCopy.Row + 1

If HowManyRows 1 Then
RngToCopy.Resize(HowManyRows, 2).FillDown
End If

.Columns("A").MergeCells = False
End With


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Fill Blank Cell Not working

1) this is wrong
.FormulaR1C1 = "r1c1"
.Value = " "
in the first line you put the letters r1c1 into the cell thenfollowed bay
puttig in a spcae
so all you need is

.Value = " "

2) this line
Range("c40:d43", Range("c" &
Rows.Count).End(xlUp)).SpecialCells(xlCellTypeBlan ks)

is odd

your range syntax is screwed
With Range(Range(X),Range(Y) )

where X and Y are the topleft and bottom right cells

so maybe
Range( Range("c40") , Range("D" & Rows.Count).End(xlUp)
).SpecialCells(xlCellTypeBlanks)







"el dee" wrote:

I have a macro that is supposed to copy and paste data from one spreadsheet
into another in the same workbook.
I need the blank cells to be filled with a space (" ") if there is not
data in it. I have the macro below.

TIA

The macro works for the data in the ("e40:e43") range, but removes the
pasted data in the ("c40:d43") range. Any ideas??

With ThisWorkbook
Set wksCopy = .Worksheets("Summary")
Set wksPaste = .Worksheets("Plot_Dominant_Rip_Veg")
End With

With Range("c40:d43", Range("c" &
Rows.Count).End(xlUp)).SpecialCells(xlCellTypeBlan ks)
.FormulaR1C1 = "r1c1"
.Value = " "
.Columns("c").MergeCells = False
End With


With Range("e40:F43", Range("e" &
Rows.Count).End(xlUp)).SpecialCells(xlCellTypeBlan ks)
.FormulaR1C1 = "r1c1"
.Value = " "
.Columns("e").MergeCells = False
End With


Set rngCopy = SetCopyRange(wksCopy, "B5:C5")
Set rngPaste = SetPasteRangeByColumn(wksPaste, "A")
rngCopy.Copy rngPaste

Set rngCopy = SetCopyRange(wksCopy, "C40:D43")
Set rngPaste = SetPasteRangeByColumn(wksPaste, "D")
rngCopy.Copy rngPaste

Set rngCopy = SetCopyRange(wksCopy, "E40:F43")
Set rngPaste = SetPasteRangeByColumn(wksPaste, "F")
rngCopy.Copy rngPaste

With Sheets("Plot_Dominant_Rip_Veg")
LastRow = .Cells(.Rows.Count, "f").End(xlUp).Row

'using the last used cell in column A to get the row to copy
Set RngToCopy = .Cells(.Rows.Count, "A").End(xlUp)

HowManyRows = LastRow - RngToCopy.Row + 1

If HowManyRows 1 Then
RngToCopy.Resize(HowManyRows, 2).FillDown
End If

.Columns("A").MergeCells = False
End With


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 a blank cell with a value using if conditions rjagathe New Users to Excel 7 December 20th 09 12:22 PM
Fill cell that is blank Slashman Excel Worksheet Functions 7 August 28th 06 01:30 AM
fill blank cell with cell above: special case Mut[_11_] Excel Programming 0 August 7th 06 04:01 AM
fill blank cell with cell above: special case Mut[_10_] Excel Programming 0 June 12th 06 03:04 AM
Fill with a formula until Cell is Blank John Excel Programming 4 June 8th 04 11:10 AM


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