format painting
Microsoft Office TrainingThe UK's Number 1 for Microsoft Office Training Sitemap add this page to your favourites/bookmarksBookmark page
 
view a printable version of this pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Format Painting

Format Painting

resolvedResolved · Medium Priority · Version 2007

replyReplyTue 8 Jun 2010, 15:58Delegate Tom said...

Format Painting

Hello,

Sorry for hogging, just another quick one...

I can find out why I cant do this...

'formats the Reforecast columns to be the same as the Forecast column

Workbooks("103 Reforecasts").Sheets("Reforecast").Columns("B:B").Copy

Workbooks("103 Reforecasts").Sheets("Reforecast").Range(Columns(3), Columns(col)).PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False

Workbooks("103 Reforecasts").Sheets("Reforecast").Application.CutCopyMode = False




The debugger doesnt like:

Workbooks("103 Reforecasts").Sheets("Reforecast").Range(Columns(3), Columns(col)).PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False


Many thanks

Tom

For upcoming training course dates see: Pricing & availability

replyReplyWed 9 Jun 2010, 17:19Trainer Stephen said...

RE: Format Painting

Hi Tom

What error message do you get when you run this?

Thanks


Stephen

replyReplyFri 11 Jun 2010, 14:04Delegate Tom said...

RE: Format Painting

Hi Stephen,

It says the following...

'Select Method of Range Class Failed' but there are several errors depending what I try in order to fix the problem.

I'll try and explain it further with this example...

This works fine...

Range("BP5:BW5").AutoFill Destination:=Range("BP5:BW9"), Type:=xlFillDefault
Range("BP5:BW9").Select

But I want to call it when that sheet is not the active sheet, so I tried this...

Workbooks("Dist Plan 103").Sheets("Team Attendance").Active
Range("BP5:BW5").AutoFill Destination:=Range("BP5:BW9"), Type:=xlFillDefault
Range("BP5:BW9").Select

This...

Workbooks("Dist Plan 103").Sheets("Team Attendance").Range("BP5:BW5").Select
Selection.AutoFill Destination:=Workbooks("Dist Plan 103").Sheets("Team Attendance").Range("BP5:BW9"), Type:=xlFillDefault
Workbooks("Dist Plan 103").Sheets("Team Attendance").Range("BP5:BW9").Select

and several other attempts and it just doesnt like it when I put the full address of the range, in particular the part about the AutoFill Destination.

Thanks again,

Tom

replyReplyThu 1 Jul 2010, 09:34Trainer Stephen said...

RE: Format Painting

Hi Tom

Thanks for update. Apologies for the delay, I have been on leave

Try selecting the sheet before you select or paste to a range on it

e.g.

Sheets("Dist Plan 103").Select
range("A1:d3").Select

You cannot select a range unless you have first selected the sheet.

In principle it is better practice not to use the select command at all, but directly set the value property of the ranges in question

e.g

Sheets("Target").Range("A1:h3").Value = Sheets("Team Attendance").Range("A1:h3").Value

This will run much more quickly and is more efficient.

Regards

Stephen

replyReplyThu 1 Jul 2010, 10:55Delegate Tom said...

RE: Format Painting

Thanks Stephen that's great.

Oh just one last thing (I sound like Columbo there!) how would you make your example change the formatting of the Target sheet to the be that of that Team Attendance tab for the ranges you mentioned?

Something like...

Sheets("Target").Range("A1:h3").Format = Sheets("Team Attendance").Range("A1:h3").Format


The drop down list of attributes available (such as .value) doesnt seem to come up when write...

Sheets("Target").Range("A1:h3").

...I want to see if there is a formatting attribute.

Lastly is attribute the right word to use!

Thanks very much for your time

Tom

 

 

Please browse our web site to find out more about
excel consultants and other Microsoft training courses.

Excel tip:

How to Spell Check an Excel 2010 Worksheet

Excel 2010 does not automatically spell check a document. So, here's how to manually spell check a worksheet.

Either select the ''Review'' tab in the Ribbon, go to the ''Proofing'' section and click ''Spelling.'' Or, simply press F7.

View all Excel hints and tips

forum postHi there,

I am trying to write the correct procudure to create a pivot table. I have recorded a macro which does the job, as below;

Recorded Procedure:

Sub CreatePivotTable()

Sheets("AR134_VBA_Template").Select
Range(&q..

» Forum post: Pivot Tables - Orientation issues?


Rate this page:
2.2/5 (213 votes cast)
Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses
Microsoft Certified Partner
Security Seal verified by visa, mastercard securecard

Mini sitemap. These are the main areas of our web site. Full sitemap.

Management training

Professional Skills courses
Project Management Course London
Project Management Courses London
Project Management Training London
Project Management Training
Project Seminar
Project Seminars
Time Management Course London
Time Management London
Time Management Courses London
Time Management Training London
Introduction to Finance course
Assertiveness Skills course
Effective Communications Skills training
Presentation Skills London

Training Formats

Public scheduled courses
On-site training
Closed company courses

Consultancy
Application Development

Blogs

Excel Training
MS Project Training
Microsoft Training Blog

Version differences

Office 2010 vs 2007
MS Project version differences

Training Information

London Computer Training
Computer Training London
Docklands Training Courses
Docklands Training London

Training venues London
Client list
FAQ
Pricing and availability
Course details / Syllabus

Training Articles
Training Information

Microsoft training

Microsoft Office training
& IT Applications

Microsoft Project training
Microsoft Outlook training
Microsoft Powerpoint training
Microsoft Word training
MS Project courses
MS Project training
Outlook courses
PowerPoint courses
PowerPoint training
VBA courses
Word courses
Microsoft.training
(more...)

Excel Training

Excel courses
Excel Training Courses Medway
Autonumber in Excel
Microsoft Excel training
Basic Excel Courses
Basic Excel Course
Basic Excel Training

Interested in MS Access training?

Access courses
Microsoft Access training
Microsoft access courses
Microsoft training access course
Microsoft+access+training
Access courses in london

Training provider

Training providers
IT training companies
IT training providers
Management Training providers
Management Training provider

Event history, feedback results
Events in 2012 · 2011 · 2010 · More

See also

Crystal Reports training