If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Selection.PasteSpecial

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-01-11, 09:13
plsh plsh is offline
Registered User
 
Join Date: Nov 2004
Posts: 253
Selection.PasteSpecial

Good day,

I have a spreadsheet with a Macro.
My code is as follows:
Range("Z4:Z29").Select
Selection.Copy
Range("AC4").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

All fields Z4:Z29 and AC4 range are formatted as Number with 2 decimals yet after the macro runs and pastes the values from Z4:Z29 they appear to be formatted as text and a little block appears that says:
"The number in this cell is formatted as text or preceded by an apostrophe"

Please can you help?
Reply With Quote
  #2 (permalink)  
Old 12-01-11, 17:58
Colin Legg Colin Legg is offline
Registered User
 
Join Date: Sep 2008
Location: London, UK
Posts: 495
Hi,

Try this:
Code:
Range("Z4:Z29").Copy
Range("AC4").PasteSpecial Paste:=xlPasteValuesAndNumberFormats
__________________
Colin

RAD Excel Blog

Other tutorials:
Array Formulas | Deleting Rows with VBA
Reply With Quote
  #3 (permalink)  
Old 12-02-11, 03:30
plsh plsh is offline
Registered User
 
Join Date: Nov 2004
Posts: 253
That also doesn't work, same outcome as before unfortunately.
Reply With Quote
  #4 (permalink)  
Old 12-02-11, 05:01
Colin Legg Colin Legg is offline
Registered User
 
Join Date: Sep 2008
Location: London, UK
Posts: 495
Hmmm... are you sure that Z4:Z29 aren't numbers formatted as text too? It'd be great if you would zip and attach your workbook?
__________________
Colin

RAD Excel Blog

Other tutorials:
Array Formulas | Deleting Rows with VBA
Reply With Quote
  #5 (permalink)  
Old 12-08-11, 03:13
plsh plsh is offline
Registered User
 
Join Date: Nov 2004
Posts: 253
Yes I am sure. I have even formatted the cells as numbers again just to make sure. I won't be able to zip and upload, network constraints I am afraid.
Reply With Quote
  #6 (permalink)  
Old 12-08-11, 05:30
Colin Legg Colin Legg is offline
Registered User
 
Join Date: Sep 2008
Location: London, UK
Posts: 495
Hi,

To be honest, I'm not sure how that's happening then. All I can suggest is an alternative way of copying across the numbers and hope that it works for you...

Code:
With Range("AC4:AC29")
    .NumberFormat = Application.International(xlGeneralFormatName)
    .Value2 = Range("Z4:Z29").Value2
End With
__________________
Colin

RAD Excel Blog

Other tutorials:
Array Formulas | Deleting Rows with VBA
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On