Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Copy value problem... if "" then 0

Hi, the code below will copy the ActiveCell.Offset(0, 10).value... but
if
ActiveCell.Offset(0, 10).value has nothing in it, I need it to paste a
0 instead of nothing...

ActiveCell.Offset(0, 10).Copy
Sheets("Datasheet").Range("I65536").End(xlUp).Offs et(1,
0).PasteSpecial Paste:=xlPasteValues

Can anybody help please...

ste
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,173
Default Copy value problem... if "" then 0

Ste

No need to copy and paste, just assign the value directly

Sub CopyData()
Dim dVal As Double
dVal = IIf(IsEmpty(ActiveCell.Offset(0, 10).Value), 0 _
, ActiveCell.Offset(0, 10).Value)
Sheets("Datasheet").Range("I65536").End(xlUp).Offs et(1, 0).Value = dVal
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS


"ste mac" wrote in message
om...
Hi, the code below will copy the ActiveCell.Offset(0, 10).value... but
if
ActiveCell.Offset(0, 10).value has nothing in it, I need it to paste a
0 instead of nothing...

ActiveCell.Offset(0, 10).Copy
Sheets("Datasheet").Range("I65536").End(xlUp).Offs et(1,
0).PasteSpecial Paste:=xlPasteValues

Can anybody help please...

ste



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Copy value problem... if "" then 0

With Sheets("Datasheet").Range("I65536").End(xlUp).Offs et(1,0)
If Activecell.Offset(0,10).Value = "" Then
..Value = 0
Else
ActiveCell.Offset(0, 10).Copy
..PasteSpecial Paste:=xlPasteValues
End If
--

HTH

RP
(remove nothere from the email address if mailing direct)


"ste mac" wrote in message
om...
Hi, the code below will copy the ActiveCell.Offset(0, 10).value... but
if
ActiveCell.Offset(0, 10).value has nothing in it, I need it to paste a
0 instead of nothing...

ActiveCell.Offset(0, 10).Copy
Sheets("Datasheet").Range("I65536").End(xlUp).Offs et(1,
0).PasteSpecial Paste:=xlPasteValues

Can anybody help please...

ste



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Copy value problem... if "" then 0

Many Thanks to both Nick and Bob, I needed pointing in the right
direction...cheers...

ste
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
Selecting "Save As" adds "Copy of" to file name- MS Excel 2007 ronhansen Excel Discussion (Misc queries) 1 November 15th 09 09:33 PM
Shortcut to switch from "fill down" to "copy" with mouse drag RJ Dake Excel Discussion (Misc queries) 3 August 13th 09 05:35 PM
problem with Linking workbooks via "copy" and "paste link" Arkitek Excel Discussion (Misc queries) 0 December 19th 06 10:03 PM
Can you "duplicate" "copy" listboxes and code to multiple cells? HotRod Excel Programming 1 September 1st 04 05:03 PM


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"