PC Review


Reply
Thread Tools Rate Thread

Can I paste number formats only?

 
 
baldmosher
Guest
Posts: n/a
 
      5th May 2009
I'mcopying & pasting data from a database into a monthly report template. The
number formats differ depending on whether I'm copying whole numbers,
currency, decimals, etc.

There are formulas on the blank template, below the monthly data, to
calculate the year-on-year trend.

I want to copy JUST the number formats from the 12 monthly cells in one row,
down to the 12 formula cells in the next row.

Here's my failed attempt at blind-coding this:

sub paste_number_formats()

ActiveCell.Range("A1:L1").Copy
ActiveCell.Offset(1, 0).Range("A1:L1").PasteSpecial _
Paste:=xlPasteNumberFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

end sub

Of course, "=xlPasteNumberFormats" was invented by me, so this macro doesn't
work, but that's what I'm trying to do anyway.

Is this possible?
 
Reply With Quote
 
 
 
 
FSt1
Guest
Posts: n/a
 
      5th May 2009
hi
try this..

Range("A2").Select
Range("A2:L2").Copy
ActiveCell.Offset(1, 0).PasteSpecial Paste:=xlPasteFormats, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False

regards
FSt1

"baldmosher" wrote:

> I'mcopying & pasting data from a database into a monthly report template. The
> number formats differ depending on whether I'm copying whole numbers,
> currency, decimals, etc.
>
> There are formulas on the blank template, below the monthly data, to
> calculate the year-on-year trend.
>
> I want to copy JUST the number formats from the 12 monthly cells in one row,
> down to the 12 formula cells in the next row.
>
> Here's my failed attempt at blind-coding this:
>
> sub paste_number_formats()
>
> ActiveCell.Range("A1:L1").Copy
> ActiveCell.Offset(1, 0).Range("A1:L1").PasteSpecial _
> Paste:=xlPasteNumberFormats, Operation:=xlNone, _
> SkipBlanks:=False, Transpose:=False
>
> end sub
>
> Of course, "=xlPasteNumberFormats" was invented by me, so this macro doesn't
> work, but that's what I'm trying to do anyway.
>
> Is this possible?

 
Reply With Quote
 
Gary''s Student
Guest
Posts: n/a
 
      5th May 2009
Try:

Sub numFormatter()
For Each r In Range("A1:L1")
r.Offset(1, 0).NumberFormat = r.NumberFormat
Next
End Sub

--
Gary''s Student - gsnu200851


"baldmosher" wrote:

> I'mcopying & pasting data from a database into a monthly report template. The
> number formats differ depending on whether I'm copying whole numbers,
> currency, decimals, etc.
>
> There are formulas on the blank template, below the monthly data, to
> calculate the year-on-year trend.
>
> I want to copy JUST the number formats from the 12 monthly cells in one row,
> down to the 12 formula cells in the next row.
>
> Here's my failed attempt at blind-coding this:
>
> sub paste_number_formats()
>
> ActiveCell.Range("A1:L1").Copy
> ActiveCell.Offset(1, 0).Range("A1:L1").PasteSpecial _
> Paste:=xlPasteNumberFormats, Operation:=xlNone, _
> SkipBlanks:=False, Transpose:=False
>
> end sub
>
> Of course, "=xlPasteNumberFormats" was invented by me, so this macro doesn't
> work, but that's what I'm trying to do anyway.
>
> Is this possible?

 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      5th May 2009
Here is one more way...

Dim V As Variant
With Range("A1:L6")
V = .Offset(1).Value
.Copy .Cells(1).Offset(1)
.Offset(1) = V
End With

--
Rick (MVP - Excel)


"baldmosher" <(E-Mail Removed)> wrote in message
news:10D222AB-2531-426A-A488-(E-Mail Removed)...
> I'mcopying & pasting data from a database into a monthly report template.
> The
> number formats differ depending on whether I'm copying whole numbers,
> currency, decimals, etc.
>
> There are formulas on the blank template, below the monthly data, to
> calculate the year-on-year trend.
>
> I want to copy JUST the number formats from the 12 monthly cells in one
> row,
> down to the 12 formula cells in the next row.
>
> Here's my failed attempt at blind-coding this:
>
> sub paste_number_formats()
>
> ActiveCell.Range("A1:L1").Copy
> ActiveCell.Offset(1, 0).Range("A1:L1").PasteSpecial _
> Paste:=xlPasteNumberFormats, Operation:=xlNone, _
> SkipBlanks:=False, Transpose:=False
>
> end sub
>
> Of course, "=xlPasteNumberFormats" was invented by me, so this macro
> doesn't
> work, but that's what I'm trying to do anyway.
>
> Is this possible?


 
Reply With Quote
 
baldmosher
Guest
Posts: n/a
 
      6th May 2009
Hi FSt1,
Unfortunately that also pastes cell borders, which is one of the things I'm
trying to avoid.
Tom

"FSt1" wrote:

> hi
> try this..
>
> Range("A2").Select
> Range("A2:L2").Copy
> ActiveCell.Offset(1, 0).PasteSpecial Paste:=xlPasteFormats, _
> Operation:=xlNone, SkipBlanks:=False, Transpose:=False
>
> regards
> FSt1
>
> "baldmosher" wrote:
>
> > I'mcopying & pasting data from a database into a monthly report template. The
> > number formats differ depending on whether I'm copying whole numbers,
> > currency, decimals, etc.
> >
> > There are formulas on the blank template, below the monthly data, to
> > calculate the year-on-year trend.
> >
> > I want to copy JUST the number formats from the 12 monthly cells in one row,
> > down to the 12 formula cells in the next row.
> >
> > Here's my failed attempt at blind-coding this:
> >
> > sub paste_number_formats()
> >
> > ActiveCell.Range("A1:L1").Copy
> > ActiveCell.Offset(1, 0).Range("A1:L1").PasteSpecial _
> > Paste:=xlPasteNumberFormats, Operation:=xlNone, _
> > SkipBlanks:=False, Transpose:=False
> >
> > end sub
> >
> > Of course, "=xlPasteNumberFormats" was invented by me, so this macro doesn't
> > work, but that's what I'm trying to do anyway.
> >
> > Is this possible?

 
Reply With Quote
 
baldmosher
Guest
Posts: n/a
 
      6th May 2009

Thanks GS, that works a treat. I knew there would be a simple solution!

(I'm going to have a go at understanding Rick's solution, but later on when
I have more time...!)

Thanks all,
baldmosher


"Gary''s Student" wrote:

> Try:
>
> Sub numFormatter()
> For Each r In Range("A1:L1")
> r.Offset(1, 0).NumberFormat = r.NumberFormat
> Next
> End Sub
>
> --
> Gary''s Student - gsnu200851
>
>
> "baldmosher" wrote:
>
> > I'mcopying & pasting data from a database into a monthly report template. The
> > number formats differ depending on whether I'm copying whole numbers,
> > currency, decimals, etc.
> >
> > There are formulas on the blank template, below the monthly data, to
> > calculate the year-on-year trend.
> >
> > I want to copy JUST the number formats from the 12 monthly cells in one row,
> > down to the 12 formula cells in the next row.
> >
> > Here's my failed attempt at blind-coding this:
> >
> > sub paste_number_formats()
> >
> > ActiveCell.Range("A1:L1").Copy
> > ActiveCell.Offset(1, 0).Range("A1:L1").PasteSpecial _
> > Paste:=xlPasteNumberFormats, Operation:=xlNone, _
> > SkipBlanks:=False, Transpose:=False
> >
> > end sub
> >
> > Of course, "=xlPasteNumberFormats" was invented by me, so this macro doesn't
> > work, but that's what I'm trying to do anyway.
> >
> > Is this possible?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy column, paste special formulas & number formats doesn't work Beckey Microsoft Excel Misc 3 30th Jul 2009 07:51 PM
Conditional formats- paste special formats? =?Utf-8?B?amNhcm5leQ==?= Microsoft Excel Misc 1 1st Nov 2007 06:37 PM
paste conditional formats as formats =?Utf-8?B?bGVv?= Microsoft Excel Misc 2 5th Jul 2007 10:06 AM
Paste Number Formats =?Utf-8?B?R2FyeSBU?= Microsoft Excel Misc 4 25th Aug 2006 06:16 PM
How to copy and paste number formats only? Maestro_J Microsoft Excel Programming 7 17th Jul 2006 10:28 PM


Features
 

Advertising
 

Newsgroups
 


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