LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Updating Column

Sub not defined means it can't find the sub. Where did you put your code and
how are you activating it - are you trying to run it from a command button,
or calling it from another sub, or what? That might be the only problem. If
not doing this, try Insert Module from VBA editor and put it in the module as
a Public Sub:

Public Sub ConvertDecimals()
....
End Sub

Public should allow it to be "visible" to any other code. By default it
will only run with other code in the same module.

The methodology behind your code is fine, though. Just out of preference I
usually use the CurrentRegion property when I can when I have a retangular
range of contiguous cells and want to iterate through it, like this:

Dim MyRange as Range, TestCell as Range
Set MyRange = Intersect(Range("E:E"),Range("E1").CurrentRegion)
' Assuming we are in a rectangular list, this finds all filled cells in
column E)
For Each TestCell in MyRange.Cells ' loops through the cells
If TestCell.Value < "" Then TestCell.Offset(0,1).value =
TestCell.Offset(0,1).value * 1000
Next TestCell

The only reason is that this makes the task of finding the needed cells and
iterating through them easier to do (no trying to make sure my index value is
correct) and easier to read and debug. But conceptually it is no different.
So you are doing fine!

HTH
K Dales

"scott" wrote:

yes, just numbers. i got an error saying sub not defined. is there a better
way to write such a procedure or more efficient route to achieve same goal?
Would you have done it the same way?


"K Dales" wrote in message
...
Your code seems to work unless it runs into a value in F that is not able
to
be converted to a number; that is, it handles the number 99.64 and the
text
"99.64" but doesn't handle test "OOPS." Are you sure you don't have
anything
but numbers in column F?

"scott" wrote:


If Column F I have numbers with a decimal like 99.64 that I need to
multiply
by 1000 all the way down. I tried below code to go down E2 until last
cell
and multiply the value of the cell in column F (1 cell to right of E
column
I'm testing if data exists). I'm getting an error, can someone help me
out?
What am I missing?


Sub ConvertDecimals()

Dim c As Range

'set a range variable equal to the first data cell in column E
Set c = ActiveSheet.Range("E2")

'loop until a blank is encountered
Do While c < ""
c.Offset(0, 1).Value = (c.Offset(0, 1).Value) * 1000
'set c to the next cell down

Set c = c.Offset(1, 0)
Loop
End Sub






 
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
Need help updating 1 cell from other cells in same column Fernando@Sartorius Excel Discussion (Misc queries) 10 February 18th 10 02:07 PM
Copy updating column to another workbook Marysam67 Excel Worksheet Functions 1 June 10th 09 12:35 AM
Macro updating a new column each day Newbee Excel Worksheet Functions 0 July 31st 07 09:50 PM
how to: continuously updating column in new worksheet AndyFlick Excel Discussion (Misc queries) 1 December 19th 06 09:14 AM
Infinite Updating Column murphyslaw18 Excel Worksheet Functions 2 January 13th 06 02:39 AM


All times are GMT +1. The time now is 08:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"