• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Edit Entries in workheet

Hello dear helpers,
I have another question
I am looking for a bit of code when i change G5:G9 in Sheet1 it should edit the corresponding row in Sheet 2
File included
 

Attachments

  • testbestand.xlsm
    19.4 KB · Views: 4
Something like below.
Code:
Sub Knop4_Klikken()
Dim lRow As Long, tRow As Double
Dim sSht As Worksheet, tSht As Worksheet
Dim c As Range

Set sSht = Worksheets("Blad1")
Set tSht = Worksheets("Blad2")

lRow = tSht.Range("A" & Rows.Count).End(xlUp).Row
With tSht.Range("A1:A" & lRow)
    tRow = Evaluate("Match(" & sSht.Cells(3, 6).Value & "," & .Address & ",0)")
End With

For Each c In sSht.Range("G5:G9")
    If c.Value <> "" Then
        tSht.Cells(tRow, c.Row - 3).Value = c.Value
    End If
Next c

End Sub
 
Last edited:
Hello Chichiro,
Thank you for your reply, however i get an error on this line
Code:
 tRow = Evaluate("Match(" & sSht.Cells(3, 6).Value & "," & .Address & ",0)")
I used the same file as the one that I posted
Can you assist me a bit further
Thanks
 
Oh, right... I forgot that you needed to have focus on Blad2 for Match to work. Change code like below.
Code:
Sub Knop4_Klikken()
Dim lRow As Long, tRow As Double
Dim sSht As Worksheet, tSht As Worksheet
Dim c As Range

Set sSht = Worksheets("Blad1")
Set tSht = Worksheets("Blad2")

lRow = tSht.Range("A" & Rows.Count).End(xlUp).Row
Application.ScreenUpdating = False
tSht.Select
With tSht.Range("A1:A" & lRow)
    tRow = Evaluate("Match(" & sSht.Cells(3, 6).Value & "," & .Address & ",0)")
End With

For Each c In sSht.Range("G5:G9")
    If c.Value <> "" Then
        tSht.Cells(tRow, c.Row - 3).Value = c.Value
    End If
Next c
sSht.Select
Application.ScreenUpdating = True
End Sub
 
Back
Top