Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Copy Formats - Excel VBA

Posted on 2011-02-10
4
238 Views
Last Modified: 2012-06-22
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
Comment
Question by:matt_m
  • 2
  • 2
4 Comments
 
LVL 50

Accepted Solution

by:
Dave Brett earned 500 total points
ID: 34868163
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
 

Author Comment

by:matt_m
ID: 34868200
thanks Dave, I was wondering though if I could do it without a copy paste approach though?
0
 
LVL 50

Expert Comment

by:Dave Brett
ID: 34868208
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
 

Author Closing Comment

by:matt_m
ID: 34868265
ok cool, thanks for clearing that one up.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question