Visual Basic for Applications (VBA)


Range referencing in Copy and Paste Formats


Hi,
I'm trying to copy columns A through D on row "a"
Then pasting the formatting on the same columns from row "a+1" down till the end of the data.
I have defined my variable "a" and that's working fine, but for the actual copy and paste format part, I am getting a compile error with the following code:
With Sheets("Blotter")
.Range(.Range(("A" & a):("D" & a)), .Copy
End With
Sheets("Blotter").Range("A" & a + 1):("D" & a + 1).Range("A" & a + 1):("D" & a + 1).End(xlDown).Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
I think my range referencing is incorrect.
Change
.Range(.Range(("A" & a):("D" & a)), .Copy
to
.Range("A" & a & ":D" & a).Copy
and
Sheets("Blotter").Range("A" & a + 1):("D" & a + 1).Range("A" & a + 1):("D" & a + 1).End(xlDown).Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
to
With Sheets("Blotter")
.Range(.Range("A" & a + 1), .Range("D" & a + 1).End(xlDown)).PasteSpecial Paste:=xlPasteFormats
End WithRegards, Hans Vogelaar (http://www.eileenslounge.com)
Change
.Range(.Range(("A" & a):("D" & a)), .Copy
to
.Range("A" & a & ":D" & a).Copy
and
Sheets("Blotter").Range("A" & a + 1):("D" & a + 1).Range("A" & a + 1):("D" & a + 1).End(xlDown).Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
to
With Sheets("Blotter")
.Range(.Range("A" & a + 1), .Range("D" & a + 1).End(xlDown)).PasteSpecial Paste:=xlPasteFormats
End WithRegards, Hans Vogelaar (http://www.eileenslounge.com)
That worked. Thanks!

Related Links

Create Code to Update Value in Record From Previous Data Record
MSComm -Having problem receiving data from modem
Exporting Microsoft Word Review Comments to Microsoft Excel - Error 91 ??
error 1004 application defined or object defined error
Change File Names Using SQL Query to get new UID
Listbox question (prevent refresh)
Listview.listitem.key Intermitent Failure
varEntryIDs = Split(EntryIDCollection, ",")
Is it possible to use code in VBA to manipulate files in Windows Explorer?
VBA Error Run time Error "Browser recently got upgraded to IE9 from IE8
How to change destination project for imported modules?
Copy/Paste Columns from Sheet 1 to Sheet based on cell dropdown change on sheet 1
Delete Multiple Chart Titles in same worksheet using VBA
Open Statement: Get Count of Lines without using Open Twice?
cannot send email using cdo with Access 2010 (PC: Windows 7 64bit, MS Office: 32bit)
Macro to clear cell content if cell on the same row is modified based on a drop down list

Categories

MSDN
Visual Studio Design a...
Visual FoxPro
BizTalk Server
Data Platform Developm...
SQL Server
Windows Server
Dynamics
Visio 2010
Microsoft Azure
Kinect for Windows SDKs
Microsoft Partner Center
Open source Developmen...
Visual Studio LightSwi...
Peer-to-Peer Networkin...
Windows Desktop Sideba...
Windows Filtering Plat...
General Office Develop...
Excel for Developers
SharePoint Legacy Vers...
SharePoint Legacy Vers...
Cloud Services (Web an...
Azure Marketplace
Azure API Management
Azure DocumentDB
Azure App Service - AP...
Language Understanding...
Azure SQL Data Warehouse
Azure Security Center
Azure IoT Hub
Azure Time Series Insi...
Visual Studio Visualiz...
Visual FoxPro General
The Architect Role
Commerce Server 2007
Microsoft Translator D...
Training and Certifica...
Small Basic
Visual Studio Smart De...
SQL Server Reporting S...
SQL Server Documentation
Power Pivot
SQL Server Distributed...
Windows Embedded 8 Sta...
Standard 7: Misc
SQL Server 2012 Spatia...
SQL Server 2012 SQL To...
Windows Forms Designer
CRM
Dynamics 365 for Custo...
MSDN and TechNet Searc...
Known Issues for Windo...
SQL Server Protocols
Getting Started with S...
Expression Media
Customer Care Framework
AppFabric Service and ...
Architecture Events
CAT.NET
Deep Zoom Composer
General Troubleshootin...
Git, Mercurial and Dro...
Office Development wit...
Office Live Small Busi...
Parallel Computing Pla...
patterns & practices: ...
Performance Counters f...
Popfly Bugs and Sugges...
Search Server: Frequen...
Search, Organize, and ...
Service Bus EAI & EDI ...
Surface Application De...
SQL Creation
SQL Server 2014 SQL To...
SQL Server 2014 Analys...
SQL Server 2014 Report...
SQL Server 2014 In-Mem...
Visual Basic Express E...
Visual Basic Power Packs
Visual C++ 2008 (Pre-r...
Visual J# General (Ret...
Visual Studio 2008 Exp...
Visual Studio 2008 IDE...
Visual Studio Applicat...
Visual Studio Team Sys...
Windows Presentation F...
Windows XP Wireless SDK
Building Windows Store...
Windows Phone Preview ...
Kinect for Windows v2 SDK
Windows Containers
Microsoft R Server

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile