ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy value problem... if "" then 0 (https://www.excelbanter.com/excel-programming/326214-copy-value-problem-if-then-0-a.html)

ste mac

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

Nick Hodge

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




Bob Phillips[_6_]

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




ste mac[_2_]

Copy value problem... if "" then 0
 
Many Thanks to both Nick and Bob, I needed pointing in the right
direction...cheers...

ste


All times are GMT +1. The time now is 10:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com