fixing erro type mimatch to not copy duplicated data again

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
977
Office Version
  1. 2010
hello
i have this code works before i add condition to prevent copy the same data again based on column a in sheet report when i copy from sheet beginning
i would appriciate if anybody help
VBA Code:
Sub posting()
Dim lr As Integer
Dim wsh As Worksheet
Set wsh = Sheets("report")
lr = Range("b" & Rows.Count).End(xlUp).Row
If wsh.Cells(lr, 1).Value Then
MsgBox "you can't add this name"
wsh.Rows(lr).Clear
Else
wsh.Range("a" & lr + 1) = Sheets("begining").Range("b6").Value
wsh.Range("b" & lr + 1) = Sheets("begining").Range("b7").Value
 End If

End Sub
 

Some videos you may like

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Watch MrExcel Video

Forum statistics

Threads
1,126,983
Messages
5,621,966
Members
415,869
Latest member
LWSkinner

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
Top