Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy and clear problem

Hi

I am using Excel 97 (VBA)and have a problem. Basically what I want to
do is copy two cells, clear the whole sheet and then paste the
contents of the cells back onto the sheet. The problem I am having is
that as the contents of the cells are derived from a calculation on
the sheet, when it attempts to paste the contents back onto the sheet
there is nothing to paste (don't know why). I am attempting to do
this using a macro.

If you understand my problem and think you can help, please post the
relevant code.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Copy and clear problem

I would store the values of the cells in two variables, clear the
sheet, and then insert the contents of the variables back in to
the sheet.

Dim V1 As Variant
Dim V2 As Variant
V1 = Range("A1").Value '<< Change range
V2 = Range("A2").Value ' << Change range
Cells.Clear
Range("A1").Value = V1 ' << Change range
Range("A2").Value = V2 ' << Change range


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





"sminky" wrote in message
m...
Hi

I am using Excel 97 (VBA)and have a problem. Basically what I

want to
do is copy two cells, clear the whole sheet and then paste the
contents of the cells back onto the sheet. The problem I am

having is
that as the contents of the cells are derived from a

calculation on
the sheet, when it attempts to paste the contents back onto the

sheet
there is nothing to paste (don't know why). I am attempting to

do
this using a macro.

If you understand my problem and think you can help, please

post the
relevant code.

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Copy and clear problem

Hi
try doing this manually while recording a macro. Also use 'Edit - Paste
Special - Values' to paste your content

--
Regards
Frank Kabel
Frankfurt, Germany


sminky wrote:
Hi

I am using Excel 97 (VBA)and have a problem. Basically what I want

to
do is copy two cells, clear the whole sheet and then paste the
contents of the cells back onto the sheet. The problem I am having

is
that as the contents of the cells are derived from a calculation on
the sheet, when it attempts to paste the contents back onto the sheet
there is nothing to paste (don't know why). I am attempting to do
this using a macro.

If you understand my problem and think you can help, please post the
relevant code.

Thanks


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Copy and clear problem

Try this

Val1 = Range("C11").Value
Val2 = Range("D13").Value
Cells.ClearContents
Range("C11").Value = Val1
Range("D13").Value = Val2

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"sminky" wrote in message
m...
Hi

I am using Excel 97 (VBA)and have a problem. Basically what I want to
do is copy two cells, clear the whole sheet and then paste the
contents of the cells back onto the sheet. The problem I am having is
that as the contents of the cells are derived from a calculation on
the sheet, when it attempts to paste the contents back onto the sheet
there is nothing to paste (don't know why). I am attempting to do
this using a macro.

If you understand my problem and think you can help, please post the
relevant code.

Thanks



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
Clear and Copy vs Delete Barry Lennox[_2_] Excel Discussion (Misc queries) 2 December 19th 08 08:46 PM
Clear Comment problem saman110 via OfficeKB.com Excel Discussion (Misc queries) 2 August 13th 07 04:31 AM
Clear Clipboard after Copy Connie Excel Discussion (Misc queries) 2 November 8th 06 07:20 AM
clear, copy and paste Richard Leclezio Excel Programming 4 September 12th 03 05:13 PM
Clear destination, then copy betwen workbooks John Wilson Excel Programming 3 July 22nd 03 02:41 PM


All times are GMT +1. The time now is 04:13 PM.

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"