Button to add rows to different sheets & use formulas from row above

Tootlez

Board Regular
Joined
Jan 30, 2014
Messages
61
I have a feeling I've over my head, and I may just have to back down from this idea -- more because my knowledge of VBA is limited... but I know how to generally read the code.

My Set up:
I have a 6 tabbed Book: Info, Main, Inventory, Images, No of Images, Manu Info
The connections: Main uses Info & Manu Info to determine the formulated values; Inventory uses a mixture of Info and Main to gather what it needs; Images uses Main and No of Images (just a counting sheet) to gather what it needs, Manu Info stands alone.

What I'm after:
When I have gathered all my data in the Info tab, I want to click a button: "Finished" that will count how many rows there are, and in Main, Inventory and Images drag down the information (pre-formulated in the first row) that many of rows.

I found a tutorial with a button which adds a row, but I can't figure how to add a row to a different sheet, AND grab the formula from the row above.
I started with the tutorial of the button and I have a cell above the button that counts the number of rows i currently have (which varies from import to import) -- but i just am not sure where to go from there.


I have been finishing my Info, and going through each tab and dragging it down --- I just thought this would help save a few more minutes in the long run -- but if anything it will help me play around with some VBA.
 
Urgh ... T_T

I wanted to say that this was solved, but I am running into an error, I keep getting 1004.

I wanted to put this into my template so that it was ready to go for the next time that start a project, but now it's giving me an error every time that I run it. Something about the merged cells and something ...

I am copying my completed and working code into the other sheet's code for the button, making sure that my button is named the correct name, I even went through and made it a Private Sub so that it wouldn't try to read it from the other sheet.

I'm going back and forth from the sheet that I started with and had it working trying to figure this out, but it's not making any sense. I even went to the extent of trying to imitate how i originally started with the button after my long list of fake items, and I'm at a loss.

Possible things running through my head:
Can I not have the same name of button in different sheets (open at the same time?) -- even though this isn't my error?
I've tried changing all of the Cells(#, x) to all the different things I can think of, and nothing seems to work with that idea...
 
Upvote 0

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Whats the exact error youre getting and on what line of code?
Did you maybe try running the code with only the headers in your sheet "Info"? That would return LastRow = 1 and if you use LastRow - 1 in your code, things would get messy
 
Last edited:
Upvote 0
The error is Run-time '1004' AutoFill method of Range class has failed and it highlights these two lines with the arrow on the second line:

Code:
  .Range(.Cells(2, 1), .Cells(2, LastCol)).AutoFill _
            Destination:=.Range(.Cells(2, 1), .Cells(lastRow - 1, LastCol))

I might have figured out at least the merged cell error i was getting, and I'm testing it now.
 
Upvote 0
Ok, I think I found what was causing the error(s), and it's something that wouldn't happen during a truly finished piece.

I have little minor notes for some of the columns and when I fill in the data, it overwrites those notes, and then button works fine after that.
My merged cell error was because I had a merged cell in row 3 of Main (i just unmerged it).

I think that i was getting frustrated after being so excited that it was working to find out that my template set up needed a little adjusting.
 
Upvote 0
(Sorry had to dart out yesterday)

As far as I know it seems to be working great!

I'm going to do a little more testing so make sure that if I have a bunch of blank cells (meaning that a group of items don't have all of the columns filled out) that it still works. (it should since the A column will always have something in it no matter what)
 
Upvote 0

Forum statistics

Threads
1,215,055
Messages
6,122,902
Members
449,097
Latest member
dbomb1414

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