• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • SALE 20% Off All Courses
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Logout
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Run-time error '1004'|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Run-time error '1004'|VBA & Macros|Excel Forum|My Online Training Hub

sale now on

Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosRun-time error '1004'
sp_PrintTopic sp_TopicIcon
Run-time error '1004'
Avatar
mymalone
Member
Members
Level 0
Forum Posts: 104
Member Since:
August 25, 2017
sp_UserOfflineSmall Offline
1
September 23, 2017 - 11:06 pm
sp_Permalink sp_Print

I have a macro and received error message, cannot change part of a merged cell.  Can someone tell me what I am doing wrong and what is the solution.

Here is my macro

Dim myArray (0 to 1000) As Variant

Workbooks("MGN-JULY 2017_Final Report").Worksheets(Sheet2").Range("J94:L94").Copy Destination:=Workbooks("MGN_SortMacro_JULY 2017").Worksheets ("TEST H2").Range("E5:P5")

End Sub

 

Columns E5:P5 are merged.

 

Thanks

sp_AnswersTopicSeeAnswer See Answer
Avatar
Anders Sehlstedt
Eskilstuna, Sweden

VIP
Members


Trusted Members
Level 3
Forum Posts: 858
Member Since:
December 7, 2016
sp_UserOfflineSmall Offline
2
September 24, 2017 - 10:13 pm
sp_Permalink sp_Print

Hello,

I am just a basic user of VBA, but I will try to give some help anyway.

What first strikes me is that your range where you copy the data from is three cells, J94, K94 and L94. But the range where you want to paste it in is scripted to be a range of 12 cells. That is probably the main reason to your issue, the merged cells.

In this forum I found that when the user used xlPasteValuesAndNumberFormats it worked fine to paste the values to merged cells. Do test to use the PasteSpecial method. I am also linking to a useful site where you can read more about using PasteSpecial.

Best of luck!

Br,

Anders

sp_AnswersTopicAnswer
Answers Post
Avatar
mymalone
Member
Members
Level 0
Forum Posts: 104
Member Since:
August 25, 2017
sp_UserOfflineSmall Offline
3
September 28, 2017 - 3:57 am
sp_Permalink sp_Print

Mr. Anders

This is most helpful...was able to make adjustment to macro.

Thank you so very much!!

Avatar
Anders Sehlstedt
Eskilstuna, Sweden

VIP
Members


Trusted Members
Level 3
Forum Posts: 858
Member Since:
December 7, 2016
sp_UserOfflineSmall Offline
4
September 28, 2017 - 7:23 am
sp_Permalink sp_Print

Hello,

That's great you found a solution.

Br,

Anders

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 170
Currently Online: Riny van Eekelen, Jose Molina, Victoria Turner
Guest(s) 101
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 858
Velouria: 580
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 214
A.Maurizio: 202
Aye Mu: 201
Jessica Stewart: 189
Newest Members:
Richard Adams
Vincent Starcevich
Patrick Lawrence
Louise Bell
GIJO GEORGE
Kumud Patel
Atos Franzon
Andrew MacDonald
Artie Ball
Jenn Cain
Forum Stats:
Groups: 3
Forums: 24
Topics: 6079
Posts: 26684

 

Member Stats:
Guest Posters: 49
Members: 31571
Moderators: 2
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
trustpilot excellent rating
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved

Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.