#1
|
|||
|
|||
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 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. |
#2
|
|||
|
|||
Worksheets("Commissions").Range(Cells(i, 3)).Value
should be either Worksheets("Commissions").Cells(i, 3).Value or Worksheets("Commissions").Range("C" & i).Value note that these are how you referred to the other single cells within the procedure. |
#3
|
|||
|
|||
Woooot!
Thank you so much NoSparks! It really was a Newbie mistake. Solved. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
VBA Newbie (Trying to write a code to copy and paste info from one sheet to another) | Forum2000s | Excel Programming | 2 | 05-07-2017 04:51 AM |
How to copy excel sheet withe HEADER and Paste into new sheet? | cloudforgiven | Excel Programming | 6 | 01-05-2017 07:30 PM |
Find matching criterior in sheet 1 and copy to Sheet 2 | Auto | Excel Programming | 3 | 03-19-2016 01:41 PM |
If two geographical data match in two sheets, copy unique id/code found in one sheet | alliage | Excel | 1 | 09-01-2011 05:23 AM |
copy cell from sheet 2 to sheet 3 macro | slipperyjim | Excel Programming | 1 | 02-18-2010 01:31 AM |