Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
tod tod is offline
external usenet poster
 
Posts: 114
Default Better way to apply change to column of values

I have a column with dates and times. I want to take the
date out. So I'm doing it like this:

For each Cell in ActiveSheet.Range("A2:A10000")
Cell.Value = Cell.Value - Int(Cell.Value)
Next Cell

This works, but it adds minutes to the procedure. Is
there a statement or other that will just make the change
to the entire range at once?

tod
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Better way to apply change to column of values

one way:

Dim vArr As Variant
Dim i As Long
With ActiveSheet.Range("A2:A10000")
vArr = .Value
For i = 1 To UBound(vArr)
vArr(i, 1) = Int(vArr(i, 1))
Next i
.Value = vArr
End With


In article ,
"Tod" wrote:

I have a column with dates and times. I want to take the
date out. So I'm doing it like this:

For each Cell in ActiveSheet.Range("A2:A10000")
Cell.Value = Cell.Value - Int(Cell.Value)
Next Cell

This works, but it adds minutes to the procedure. Is
there a statement or other that will just make the change
to the entire range at once?

  #3   Report Post  
Posted to microsoft.public.excel.programming
tod tod is offline
external usenet poster
 
Posts: 114
Default Better way to apply change to column of values

Wow! Big difference. Thanx.

-----Original Message-----
one way:

Dim vArr As Variant
Dim i As Long
With ActiveSheet.Range("A2:A10000")
vArr = .Value
For i = 1 To UBound(vArr)
vArr(i, 1) = Int(vArr(i, 1))
Next i
.Value = vArr
End With


In article ,
"Tod" wrote:

I have a column with dates and times. I want to take

the
date out. So I'm doing it like this:

For each Cell in ActiveSheet.Range("A2:A10000")
Cell.Value = Cell.Value - Int(Cell.Value)
Next Cell

This works, but it adds minutes to the procedure. Is
there a statement or other that will just make the

change
to the entire range at once?

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Better way to apply change to column of values

Tod,

Using the worksheet is a good way:

If column B is blank:

With ActiveSheet.Range("B2:10000")
.Formula = "=A2-INT(A2)"
.Copy
Range("A2:A10000").PasteSpecial (xlValues)
.Clear
End With




--
HTH,
Bernie
MS Excel MVP
"Tod" wrote in message
...
I have a column with dates and times. I want to take the
date out. So I'm doing it like this:

For each Cell in ActiveSheet.Range("A2:A10000")
Cell.Value = Cell.Value - Int(Cell.Value)
Next Cell

This works, but it adds minutes to the procedure. Is
there a statement or other that will just make the change
to the entire range at once?

tod



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
change values in a column dmack Excel Discussion (Misc queries) 3 April 21st 08 11:26 PM
How can I change all negative values in a column to = 0? dbsavoy Excel Worksheet Functions 3 August 21st 06 08:14 PM
macro to change multiple values in a column mrwawa Excel Discussion (Misc queries) 7 July 2nd 06 04:35 PM
Change all values in an excel column at once? Sn0wman Excel Discussion (Misc queries) 4 April 25th 05 01:08 PM
How do I apply a Function to a column of cells and change there va Froggy New Users to Excel 1 December 23rd 04 12:09 AM


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