View Single Post
 
Old 06-28-2017, 09:40 AM
Seiquo Seiquo is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Jun 2017
Posts: 4
Seiquo is on a distinguished road
Default VBA code If... then... copy... from one sheet to another

Hello Forum,

First please let me tell you that I am new to VBA (just starting to explore the possibilities) and that English is not my mother tongue so please forgive me for any mistakes I could make.

I need your help with a code I am trying to write in VBA with no success.

I am working with a workbook that contains 2 sheets : Releve and Commissions
In cell J9 of Releve, I choose a reference number wich trigger formulas in different other cells in the sheet, whose data come from Commissions.

Column C of Commissions contains the reference number that can be repeated several times, from C4 to C1000. E.g. :

PC-1
MM-2
PC-2
PR-3
PR-3
PC-1
etc.

What I am trying to do is to copy the date in F5 (=today()) of Releve to column N of Commissions, only if the reference number is the same. Here is the code I have started writing but I get an syntax error :

Code:
Sub ValidatePay()
    With Worksheets("Commissions")
    For i = 1000 To 4 Step -1
    If Worksheets("Commissions").Range(Cells(i, 3)).Value = Worksheets("Releve").Range("J9").Value Then_
 Worksheets("Commissions").Cells(i, 14) = Worksheets("Releve").Range("F5").Value
    Next i
 
    End With
End Sub
This will allow the user to automatically copy the date value to the different rows corresponding to the reference number, at once.

Since it won't work I suppose this code looks like a funny mess for any Professional but I really want to learn

I am including my test file to help.

thank you so much in advance.
Attached Files
File Type: xlsm Test_Forum.xlsm (164.5 KB, 10 views)
Reply With Quote