Editing something via macro?

Antonow

New Member
Joined
Aug 19, 2015
Messages
39
Hello everyone, It´s been a long time since i´ve been here! and i need your help one more time.

I´m developing a spreadsheet where i have to input something like the following.

MoldModelComp 1Quant 1Comp 2Quant 2Comp 3Quant 3Comp 4Quant 4StatusData

<tbody>
</tbody>

I have 2 worksheets, one labeled Input and another one labeled Vorlagen.

I managed to make the input macro, where it gets the information from Input, places it in Vorlagen and clear the information from the input worksheet, here is the code:
Code:
Sub Vorlagen_Input()

    'Sheets("Input").Unprotect Password:="Verboten"
    'Sheets("Vorlagen").Unprotect Password:="Verboten"


    Dim ws1 As Worksheet
    Dim ws2 As Worksheet
    Dim NextRow As Long


    Set ws1 = ThisWorkbook.Worksheets("Input")
    Set ws2 = ThisWorkbook.Worksheets("Vorlagen")


    With ws2
    
        NextRow = .Cells(.Rows.Count, "B").End(xlUp).Row + 1
        .Cells(NextRow, "B") = ws1.Cells(4, "B").Value  ' Schimmel
        .Cells(NextRow, "C") = ws1.Cells(4, "C").Value  ' Modell
        .Cells(NextRow, "D") = ws1.Cells(4, "D").Value  ' Komponente 1
        .Cells(NextRow, "E") = ws1.Cells(4, "E").Value  ' Anzahl 1
        .Cells(NextRow, "F") = ws1.Cells(4, "F").Value  ' Komponente 2
        .Cells(NextRow, "G") = ws1.Cells(4, "G").Value  ' Anzahl 2
        .Cells(NextRow, "H") = ws1.Cells(4, "H").Value  ' Komponente 3
        .Cells(NextRow, "I") = ws1.Cells(4, "I").Value  ' Anzahl 3
        .Cells(NextRow, "J") = ws1.Cells(4, "J").Value  ' Komponente 4
        .Cells(NextRow, "K") = ws1.Cells(4, "K").Value  ' Anzahl 4
        .Cells(NextRow, "L") = ws1.Cells(4, "L").Value  ' Status
        .Cells(NextRow, "M") = ws1.Cells(4, "M").Value  ' Daten


    'Sheets("Input").Protect Password:="Verboten"
    'Sheets("Vorlagen").Protect Password:="Verboten
    
    End With
    
    Range("B4:M4").Select
    Selection.ClearContents
    Range("B4").Select

What i'd like to do is, have a worksheet or a button in the Input worksheet, that when you select a Mold from a dropdown list, it gets the information of that one and if you need to change lets say.. its status, you change and press "Update" and it will update it in the Vorlagen worksheet. I've been hitting my head against the keyboard for hours and I can't seem to make it work. Can you guys help?

Btw, i'm sorry for any grammatical error.. It's been a while since i've used English. :)
 
Last edited:

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
If ive read correctly you need this part:

Code:
With ws2

to be dependant on the dropdown cell value? Is that correct?
 
Upvote 0
Ok. Change the first part to the sheet and cell reference of your dropdown and change 'update' to whatever you say in the cell then you can set your variable like this:

Code:
If Sheets("Sheet1").Range("A1").Value = "update" Then
    NextRow = Application.Match(ws1.Cells(4, "C").Value, ws2.Columns("C"), 0)
Else
    NextRow = ws2.Cells(Rows.Count, "B").End(xlUp).Row + 1
End If

If IsError(NextRow) Then
    MsgBox "There is no match found. You cannot update"
    Exit Sub
End If
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,030
Messages
6,128,408
Members
449,448
Latest member
Andrew Slatter

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