Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default ActiveCell.PasteSpecial (xlPasteValues) hangs program

I have a worksheet with formula that auto-eneters the date (NOW()),
based on the value of another cell. The cell is either todays date, or
an emopty string.

==IF(I26=0,NOW(),"")

When exiting the sheet I want to convert any dates entered to thier
literal value (i.e remove the formula) so that the date is not
overwritten with a future date when the sheet is reopened.

This code works, but takes a very long time , and when stepping
through I see it hangs for several seconds on each call to
pastespecial, making it take over 10 minutes for 3000 rows.

Any reason for this - is thier a faster way to achieve the same
result?
thanks,hals_left

For Each Cell In Worksheets(1).Range("myRange")
If IsDate(Cell.Value) Then
Cell.Select
Cell.Copy

ActiveCell.PasteSpecial (xlPasteValues)
End If
Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default ActiveCell.PasteSpecial (xlPasteValues) hangs program

Try the following

Sub ReplaceIt()
Dim a As Range

For Each a In Worksheets(1).Range("myRange").Areas
a.Copy
a.PasteSpecial xlPasteValues

Next a

End Sub

Kevin Beckham

-----Original Message-----
I have a worksheet with formula that auto-eneters the

date (NOW()),
based on the value of another cell. The cell is either

todays date, or
an emopty string.

==IF(I26=0,NOW(),"")

When exiting the sheet I want to convert any dates

entered to thier
literal value (i.e remove the formula) so that the date

is not
overwritten with a future date when the sheet is

reopened.

This code works, but takes a very long time , and when

stepping
through I see it hangs for several seconds on each call to
pastespecial, making it take over 10 minutes for 3000

rows.

Any reason for this - is thier a faster way to achieve

the same
result?
thanks,hals_left

For Each Cell In Worksheets(1).Range("myRange")
If IsDate(Cell.Value) Then
Cell.Select
Cell.Copy

ActiveCell.PasteSpecial (xlPasteValues)
End If
Next
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default ActiveCell.PasteSpecial (xlPasteValues) hangs program


Following is an alternative to kevin's code

a.formula=a.value


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Kevin Beckham" wrote:

Try the following

Sub ReplaceIt()
Dim a As Range

For Each a In Worksheets(1).Range("myRange").Areas
a.Copy
a.PasteSpecial xlPasteValues

Next a

End Sub

Kevin Beckham

-----Original Message-----
I have a worksheet with formula that auto-eneters the

date (NOW()),
based on the value of another cell. The cell is either

todays date, or
an emopty string.

==IF(I26=0,NOW(),"")

When exiting the sheet I want to convert any dates

entered to thier
literal value (i.e remove the formula) so that the date

is not
overwritten with a future date when the sheet is

reopened.

This code works, but takes a very long time , and when

stepping
through I see it hangs for several seconds on each call to
pastespecial, making it take over 10 minutes for 3000

rows.

Any reason for this - is thier a faster way to achieve

the same
result?
thanks,hals_left

For Each Cell In Worksheets(1).Range("myRange")
If IsDate(Cell.Value) Then
Cell.Select
Cell.Copy

ActiveCell.PasteSpecial (xlPasteValues)
End If
Next
.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default ActiveCell.PasteSpecial (xlPasteValues) hangs program

The areas doesnt seem to work at all, formulae are left in the cells
with a valid date, so wjhen i re-open the worksheet another day, the
dates change.

Sub toText()
Dim objRange As Range
For Each objRange In Worksheets(1).Range("dateColumn").Areas
If IsDate(objRange.Value) Then
objRange.Formula = objRange.Value
End If
Next
End Sub

"Kevin Beckham" wrote in message ...
Try the following

Sub ReplaceIt()
Dim a As Range

For Each a In Worksheets(1).Range("myRange").Areas
a.Copy
a.PasteSpecial xlPasteValues

Next a

End Sub

Kevin Beckham

-----Original Message-----
I have a worksheet with formula that auto-eneters the

date (NOW()),
based on the value of another cell. The cell is either

todays date, or
an emopty string.

==IF(I26=0,NOW(),"")

When exiting the sheet I want to convert any dates

entered to thier
literal value (i.e remove the formula) so that the date

is not
overwritten with a future date when the sheet is

reopened.

This code works, but takes a very long time , and when

stepping
through I see it hangs for several seconds on each call to
pastespecial, making it take over 10 minutes for 3000

rows.

Any reason for this - is thier a faster way to achieve

the same
result?
thanks,hals_left

For Each Cell In Worksheets(1).Range("myRange")
If IsDate(Cell.Value) Then
Cell.Select
Cell.Copy

ActiveCell.PasteSpecial (xlPasteValues)
End If
Next
.

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
If activecell.column = variable then activecell,offset (0,1) Battykoda via OfficeKB.com Excel Discussion (Misc queries) 1 October 2nd 07 08:05 PM
2007 - Program Hangs when Viewing Worksheets Deanna Reynolds Excel Discussion (Misc queries) 0 October 14th 06 09:47 PM
pastespecial Claude Excel Programming 2 February 24th 04 01:21 PM
pastespecial in vba cornishbloke[_13_] Excel Programming 7 December 31st 03 01:02 PM
merging excel program with tdc finance program judy Excel Programming 0 November 5th 03 08:01 PM


All times are GMT +1. The time now is 03:12 PM.

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"