SOLVED

VBA Excel : Error 1004 - Delete Method out of Range class failed

Copper Contributor

Hello can you help me ? 

i get error1004 after executing this macro, it has something to do with delete method could you please help me fixing that ?

(Base bellow for testing)

 

MicrosoftNewbie121_0-1706104045692.png

 

 

2 Replies
best response confirmed by MicrosoftNewbie121 (Copper Contributor)
Solution

@MicrosoftNewbie121 

The code tries to delete the header row of the table on Updated.

To avoid that, change the line

    Set idCol2 = WSheet2.Range("B2:B" & lastRow2)

to

    Set idCol2 = WSheet2.Range("B3:B" & lastRow2)

 

Thank you sooo much for your help :) it's working like a charm !
1 best response

Accepted Solutions
best response confirmed by MicrosoftNewbie121 (Copper Contributor)
Solution

@MicrosoftNewbie121 

The code tries to delete the header row of the table on Updated.

To avoid that, change the line

    Set idCol2 = WSheet2.Range("B2:B" & lastRow2)

to

    Set idCol2 = WSheet2.Range("B3:B" & lastRow2)

 

View solution in original post