fixing erro type mimatch to not copy duplicated data again

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
1,429
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
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
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,213,484
Messages
6,113,920
Members
448,533
Latest member
thietbibeboiwasaco

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