ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Paste column as number (https://www.excelbanter.com/excel-programming/348604-paste-column-number.html)

[email protected]

Paste column as number
 
Hi,

I am pasting columns from one sheet to another. Some columns are
formatted as text, even though they only contain numbers. Other columns
do contain text. Is there a generic way to paste columns so that if
they are numbers, they are pasted as numbers, but if they are text
strings, they are pasted as text?

Thanks


Niek Otten

Paste column as number
 
Not in the Copy or Paste method, AFAIK
But you can correct this as follows:
Format an empty cell as general. EditCopt.
Select your data. EditPaste special, check Add.

--
Kind regards,

Niek Otten

wrote in message
oups.com...
Hi,

I am pasting columns from one sheet to another. Some columns are
formatted as text, even though they only contain numbers. Other columns
do contain text. Is there a generic way to paste columns so that if
they are numbers, they are pasted as numbers, but if they are text
strings, they are pasted as text?

Thanks




Niek Otten

Paste column as number
 
<EditCopt

should of course be

EditCopy

--
Kind regards,

Niek Otten

"Niek Otten" wrote in message
...
Not in the Copy or Paste method, AFAIK
But you can correct this as follows:
Format an empty cell as general. EditCopt.
Select your data. EditPaste special, check Add.

--
Kind regards,

Niek Otten

wrote in message
oups.com...
Hi,

I am pasting columns from one sheet to another. Some columns are
formatted as text, even though they only contain numbers. Other columns
do contain text. Is there a generic way to paste columns so that if
they are numbers, they are pasted as numbers, but if they are text
strings, they are pasted as text?

Thanks






[email protected]

Paste column as number
 
Whoops - Forgot to mention that this is done using VB Script...

Thanks for your response anyway - I feel dumb now :/


Niek Otten

Paste column as number
 
I guessed that :-)
Do the actions once manually with the Macro recorder engaged and copy/amend
the code to include in your script

--
Kind regards,

Niek Otten

wrote in message
oups.com...
Whoops - Forgot to mention that this is done using VB Script...

Thanks for your response anyway - I feel dumb now :/




Tom Ogilvy

Paste column as number
 
columns(1).copy
Worksheets(2).columns(3).PasteSpecial xlValues

What does that do for you.

--
Regards,
Tom Ogilvy


wrote in message
oups.com...
Whoops - Forgot to mention that this is done using VB Script...

Thanks for your response anyway - I feel dumb now :/




[email protected]

Paste column as number
 
Hi - tried it (xlValues), but no luck. The problem with the copy and
paste is that I am doing it from the same column.


Tom Ogilvy

Paste column as number
 
Sub AdjustColumn()
Dim rng As Range
Dim cell As Range
Set cell = Selection
Set rng = Intersect(ActiveCell.EntireColumn, _
ActiveSheet.UsedRange)
rng.NumberFormat = "General"
With Range("IV1")
.Value = 1
.Copy
End With
rng.SpecialCells(xlConstants).PasteSpecial _
xlValues, xlMultiply
Columns(256).Delete
ActiveSheet.UsedRange
cell.Select
End Sub

--
Regards,
Tom Ogilvy

wrote in message
oups.com...
Hi - tried it (xlValues), but no luck. The problem with the copy and
paste is that I am doing it from the same column.





All times are GMT +1. The time now is 07:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com