[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 274
  • Last Modified:

Copy Formats - Excel VBA

Hi All

Quick question here, I was wondering whether it was possible to copy the formats using VBA between two ranges in an anologious fashion to the below (which copies values)

Range(Cells(10, 1), Cells(50, 1)).Value = Range(Cells(10, 2), Cells(50, 2)).Value

ie something along the lines of the below (which doesn't seem to work)

Range(Cells(10, 1), Cells(50, 1)).Format = Range(Cells(10, 2), Cells(50, 2)).Format

Thanks!
Matt
0
matt_m
Asked:
matt_m
  • 2
  • 2
1 Solution
 
Dave BrettCommented:
soemthing like this

Dave
Range(Cells(10, 1), Cells(50, 1)).Copy
Range(Cells(10, 2), Cells(50, 2)).PasteSpecial Paste:=xlPasteFormats
Application.CutCopyMode = False

Open in new window

0
 
matt_mAuthor Commented:
thanks Dave, I was wondering though if I could do it without a copy paste approach though?
0
 
Dave BrettCommented:
you can't :)

The purpose of this line is to remove the copied selection
Application.CutCopyMode = False

So you can hide what has been done, but there isn't an equivalent of the format code that intuition says may be there

Cheers

Dave
0
 
matt_mAuthor Commented:
ok cool, thanks for clearing that one up.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now