looking for VBA code

Wloven

New Member
Joined
Nov 28, 2020
Messages
8
Office Version
  1. 365
Platform
  1. Windows
I am trying to create a VBA code which copy a cell and paste with three condition:
1- If the cell next to the cell targeted is not duplicate.
2- will continue to paste this data till the certain number exceed.
3- will copy another cell and paste with the two above condition also.

(the picture below explain more:
a) the S columns is the target cell where I want to paste.
b) the red circle is the number of how many each name highlighted in yellow should paste.
c) they should not paste if Duplicate appear in columns AA.
Capture.JPG
 
Thank you Zot but the code not working, it not do anything.
Sales DocumentAssign ToiBase LinkedContract NumberWasKirTas
19​
4364823
441283Sales39
20​
440115How Many6
0​
440826
440826Duplicate
440826Duplicate
440826Duplicate
440705
440705Duplicate
440706
440706Duplicate
440707
440707Duplicate
440263
440263Duplicate
440264
440264Duplicate
438251
441497
436315
436384
436384Duplicate
436326
437449
437449Duplicate
437449Duplicate
437469
437469Duplicate
437469Duplicate
437477
437477Duplicate
437477Duplicate
437441
437466
437466Duplicate
437466Duplicate
437481
437481Duplicate
437481Duplicate
 
Upvote 0

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
It should work since I tried it based on your sheet as displayed.

How many is in X4. I should have asked where the 13 came from since your sample has X4 = 11.25 (not 13)

Anyway, your initial sample put name in W5, X5, Y5 as WA, KI, TA. I put them in W1, X1, ...

Are you sure you put exactly in same columns as sample? I could not understand why it did nothing. I added name Tas and worked just fine
 
Upvote 0
It should work since I tried it based on your sheet as displayed.

How many is in X4. I should have asked where the 13 came from since your sample has X4 = 11.25 (not 13)

Anyway, your initial sample put name in W5, X5, Y5 as WA, KI, TA. I put them in W1, X1, ...

Are you sure you put exactly in same columns as sample? I could not understand why it did nothing. I added name Tas and worked just fine
I changed Set wb = ThisWorkbook to Set wb = ActiveWorkbook and it's worked as I have different excel to work with. Thank you for your help.
 
Upvote 0
I changed Set wb = ThisWorkbook to Set wb = ActiveWorkbook and it's worked as I have different excel to work with. Thank you for your help.
Glad to hear that it worked. I have no idea that ThisWorkbook is no more working on new 365 Excel :oops:
 
Upvote 0

Forum statistics

Threads
1,216,082
Messages
6,128,700
Members
449,464
Latest member
againofsoul

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