#1   Report Post  
Posted to microsoft.public.excel.misc
Joe Joe is offline
external usenet poster
 
Posts: 476
Default Fill blank values

Hi Experts,

I'm copying values from one sheet and pasting onto other sheet. In the cells
that I'm copying, there are cells with no values, however while pasting I
want to replace blank cells with 0.

My sample code which copies and pastes the values is as below:
For example, Column A has few blanks cells. I want to substitute blank cells
with 0.
*****************
Sub CopyValues()

Dim NewSet As String
Dim NewSet1 As String
Dim NewSet2 As String
Dim NewSet3 As String
Dim NewSet4 As String
Dim NewSet5 As String
Dim CurLocation As String

CurLocation = ActiveCell.Address

Sheets("Source").Select
Columns("A:G").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Target").Select
Columns("A:G").Select

ActiveSheet.Paste

End Sub
************************
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 477
Default Fill blank values

Maybe adding before the End Sub Line:

With Sheets("Target").Range("A:G")
..CurrentRegion.SpecialCells(xlCellTypeBlanks) = 0
End With

Back up File Before you try !!


"Joe" wrote:

Hi Experts,

I'm copying values from one sheet and pasting onto other sheet. In the cells
that I'm copying, there are cells with no values, however while pasting I
want to replace blank cells with 0.

My sample code which copies and pastes the values is as below:
For example, Column A has few blanks cells. I want to substitute blank cells
with 0.
*****************
Sub CopyValues()

Dim NewSet As String
Dim NewSet1 As String
Dim NewSet2 As String
Dim NewSet3 As String
Dim NewSet4 As String
Dim NewSet5 As String
Dim CurLocation As String

CurLocation = ActiveCell.Address

Sheets("Source").Select
Columns("A:G").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Target").Select
Columns("A:G").Select

ActiveSheet.Paste

End Sub
************************

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Fill blank values

After you have completed the copy, run:

Sub blanks_to_zeros()
Dim r As Range
Set r = Sheets("Target").Columns("A:G").SpecialCells(xlCel lTypeBlanks)
r.Value = 0
End Sub
--
Gary's Student


"Joe" wrote:

Hi Experts,

I'm copying values from one sheet and pasting onto other sheet. In the cells
that I'm copying, there are cells with no values, however while pasting I
want to replace blank cells with 0.

My sample code which copies and pastes the values is as below:
For example, Column A has few blanks cells. I want to substitute blank cells
with 0.
*****************
Sub CopyValues()

Dim NewSet As String
Dim NewSet1 As String
Dim NewSet2 As String
Dim NewSet3 As String
Dim NewSet4 As String
Dim NewSet5 As String
Dim CurLocation As String

CurLocation = ActiveCell.Address

Sheets("Source").Select
Columns("A:G").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Target").Select
Columns("A:G").Select

ActiveSheet.Paste

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 IN BLANK CELLS Charles Excel Discussion (Misc queries) 2 August 8th 05 07:07 PM
Count Intervals of Filtered TEXT values in Column and Return Count across a Row Sam via OfficeKB.com Excel Worksheet Functions 9 July 31st 05 03:37 AM
Excel should not automatically extend series or fill values whisperlm Excel Discussion (Misc queries) 0 July 13th 05 07:06 PM
Can an excel cell automatically change fill colors based on values John Clark Excel Discussion (Misc queries) 1 February 5th 05 05:21 PM
Identifying the Active Fill Color Steve Conary Excel Discussion (Misc queries) 3 December 9th 04 04:45 AM


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