Solved

Copy Formats - Excel VBA

Posted on 2011-02-10
4
209 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
ok cool, thanks for clearing that one up.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Pivot help 3 21
second highest value difference 11 23
VLOOKUP Function MS Excel 2010 2 20
Changing absolute cell references 3 7
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

763 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now