Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Convert cell contents to number

I would like to convert all the cells with contents in Column I to a number.
I am using the following macro to do so, however I am getting zeros in rows
that do not have any contents in their cells. Can you tell me how to change
the code below so that only the cells with contents in Column I will be
converted to numbers?

Sub Macro5()
Columns("J:J").Select
Selection.Insert Shift:=xlToRight
Range("J2").Select
ActiveCell.FormulaR1C1 = "1"
Selection.Copy
Range("I2:I100").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlMultiply, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False

Columns("J:J").Delete

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Convert cell contents to number

Sub Macro5()
Columns("J:J").Select
Selection.Insert Shift:=xlToRight
Range("J2").Select
ActiveCell.FormulaR1C1 = "1"

For Each r In Range("I2:I100")
If Not IsEmpty(r) Then
Range("J2").Copy
r.Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlMultiply, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
End If
Next
Columns("J:J").Delete

End Sub
--
Gary''s Student - gsnu200909


"Jazz" wrote:

I would like to convert all the cells with contents in Column I to a number.
I am using the following macro to do so, however I am getting zeros in rows
that do not have any contents in their cells. Can you tell me how to change
the code below so that only the cells with contents in Column I will be
converted to numbers?

Sub Macro5()
Columns("J:J").Select
Selection.Insert Shift:=xlToRight
Range("J2").Select
ActiveCell.FormulaR1C1 = "1"
Selection.Copy
Range("I2:I100").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlMultiply, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False

Columns("J:J").Delete

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default Convert cell contents to number

Use this method to only apply the multiplication to cells with values in them:

=========
Sub Macro5()
Columns("J:J").Insert Shift:=xlToRight
Range("J2") = 1
Range("J2").Copy

Columns("I:I").SpecialCells(xlCellTypeConstants, 23).PasteSpecial _
Paste:=xlPasteAll, Operation:=xlMultiply

Columns("J:J").Delete

End Sub
=========

Does that help?
--
"Actually, I *am* a rocket scientist." -- JB
(www.MadRocketScientist.com)

Your feedback is appreciated, click YES if this post helped you.


"Jazz" wrote:

I would like to convert all the cells with contents in Column I to a number.
I am using the following macro to do so, however I am getting zeros in rows
that do not have any contents in their cells. Can you tell me how to change
the code below so that only the cells with contents in Column I will be
converted to numbers?

Sub Macro5()
Columns("J:J").Select
Selection.Insert Shift:=xlToRight
Range("J2").Select
ActiveCell.FormulaR1C1 = "1"
Selection.Copy
Range("I2:I100").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlMultiply, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False

Columns("J:J").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
Convert cell contents to range jgrogan Excel Worksheet Functions 3 July 17th 06 09:32 AM
How to convert cell contents Robert Judge Excel Worksheet Functions 1 June 13th 06 08:04 PM
How to convert cell contents? Robert Judge Excel Discussion (Misc queries) 0 June 8th 06 02:46 PM
How do I convert cell contents that are Hex to binary? KarenSue33 Excel Worksheet Functions 1 February 21st 05 05:41 PM
convert cell contents into a comment Paul hunter Excel Programming 5 August 21st 04 09:47 AM


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