Solved

Copy Formats - Excel VBA

Posted on 2011-02-10
4
249 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
[X]
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
  • 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

736 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