Run Time Error '1004': Application-Defined or Object Defined error

Status
Not open for further replies.

Roar70

New Member
Joined
Mar 29, 2023
Messages
7
Office Version
  1. 365
Platform
  1. Windows
Hello: I am trying to get information from a worksheet Where I have created a Form to gather information and have that information copied into another worksheet to store. I am using two Excel VBA modules to perform this actions. In module1 my macro is collecting all of my data and the calls for the opening of the second of my two macros in module2 to copy that data into my second worksheet where i plan to store it. I test run my first VBA macro and all worked as expected with collecting the data. The problem I am having is in my second macro. I Dim all my variables and Set all my worksheets. When I run the macro it stops at the command line that should find my "nextRow= command" with the Application-defined or Object-defined error code '1004'.


Dim sourceSheet As Worksheet
Dim dataSheet As Worksheet
Dim nextRow As Integer

Set sourceSheet = Sheets("Form")
Set dataSheet = Sheets("Data")

nextRow = dataSheet.Range("A" & dataSheet.Rows.Count).End(x1Up).Offset(1).Row


dataSheet.Cells(nextRow, 1).Value = sourceSheet.Range("F5").Value
dataSheet.Cells(nextRow, 2).Value = sourceSheet.Range("F7").Value

The nextRow command you see is where my program stops.

This is my firs time writing code. I thought I understood it enough to solve this problem but I guess not. Any help will be greatly appreciated and a Thank you in advance for that help.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Welcome to the Board!

It looks like you have a typo in there.

It should be "xlUp", not "x1Up"
(the second character is a lower-case "L", not the number "1").
 
Upvote 1
Solution
Welcome to the Board!

It looks like you have a typo in there.

It should be "xlUp", not "x1Up"
(the second character is a lower-case "L", not the number "1").
Thank you so much. I have looked at this screen for so long trying to see if I had entered anything wrong and could not see it for looking at it. You have made my day. Thanks again for the help.
 
Upvote 0
You are welcome.
Sometimes, it helps to have a new, fresh set of eyes looking at it (I often have a hard time spotting my own typos too!).
 
Upvote 0
i have a VBA application (available on tutorials by "Contextures" as Excel Names Macro) which runs perfectly on a laptop with Office 10 but macro from this very same file if executed from a laptop with Office 365 gives this Run-time error '1004': Application-defined or Object-defined error. What can be the reason ?
 
Last edited by a moderator:
Upvote 0
i have a VBA application (available on tutorials by "Contextures" as Excel Names Macro) which runs perfectly on a laptop with Office 10 but macro from this very same file if executed from a laptop with Office 365 gives this Run-time error '1004': Application-defined or Object-defined error. What can be the reason ?
Duplicate to: Run-time error '1004' - (happens in one laptop but not on another)

In future, please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

In relation to your question here, I have closed this thread so please continue in the linked thread.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,224,828
Messages
6,181,204
Members
453,022
Latest member
RobertV1609

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top