Update data code

richardswaim

Board Regular
Joined
May 26, 2016
Messages
109
In my workbook, I have a worksheet , Sheet1(Work Order), created by a commandbutton1, that command created a worksheet and copied Sheet1(Work Order) to that Tab and named the worksheet according to the value of cell"M1"(A16-102). At the same time, it entered data from that copied worksheet to another worksheet, Sheet2(Data). On Sheet2(Data), the name of the worksheet (A16-102) is placed in Column A, along with 5 other cells of value entered on the same row. At another point in time, I will make changes to A16-102 and will need the cells in Sheet2(Data) to reflect those changes.

I need a code that I will be able to place on each worksheet that will look at the value of Cell A in a given row and make the changes to update the data in that row. Does that make sense?

My current code is:

'Transfer information
wsDataSheet.Cells(lastRow, 1).Value = ActiveSheet.Range("M1").Value
wsDataSheet.Cells(lastRow, 2).Value = ActiveSheet.Range("J8").Value
wsDataSheet.Cells(lastRow, 3).Value = ActiveSheet.Range("G8").Value
wsDataSheet.Cells(lastRow, 4).Value = ActiveSheet.Range("O26").Value
wsDataSheet.Cells(lastRow, 5).Value = ActiveSheet.Range("O25").Value
wsDataSheet.Cells(lastRow, 6).Value = ActiveSheet.Range("O27").Value
wsDataSheet.Cells(lastRow, 7).Value = ActiveSheet.Range("N30").Value

End Sub

I believe the wsDataSheet.cells is wrong, cause Sheet2(Data) is name of the sheet I need it transferred to. I don't know that Transfer information is even the right type to use. I know it's not easy, but can I get some help?
 
Cells containing normal validation Dropdowns are not ActiveX objects you refer to them as you would any normal cell i.e.
Code:
Range("I2").Value = ""
or
Code:
Range("I2").ClearContents

where I2 would be a cell containing the validation dropdown.

Now back to the first problem...

Then when I click on the "Save" button, it puts the same A16-102 in Row 11 but does place the desired info in the rest of that Row.

Not understanding why you would have the same code in 2 different buttons. The code posted was for you to test with not to create a separate button.

It duplicates the Work Order number on 2 Rows.
Of course it will if you run a code twice on the same data because you are running it off 2 buttons

If I am missing something hat are you expecting the code to do (especially if you have the same work order being used multiple times) explain it VERY simply as if you were writing an idiot guide (because you are dealing with an idiot here) and the thread is getting long now.
 
Upvote 0

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Ok, that portion, the duplicating problem, I have that working fine, I am happy with that portion of the code. That's done. I will try the codes you sent for Clearing contents, thank you for all you have done for me, it is greatly appreciated. It has been taking 10 minutes for your responses to get to me from England, that's why it takes my response to be slow in getting back to you. It must be getting late there, so I will be happy with what has been accomplished for today. Have a good night and I will continue to ask for advice as I go on. I will start another thread with my other questions, thanks.
 
Upvote 0

Forum statistics

Threads
1,215,724
Messages
6,126,485
Members
449,316
Latest member
sravya

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