Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-28-2017, 09:40 AM
Seiquo Seiquo is offline VBA code If... then... copy... from one sheet to another Windows 7 64bit VBA code If... then... copy... from one sheet to another Office 2010 64bit
Novice
VBA code If... then... copy... from one sheet to another
 
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, 8 views)
Reply With Quote
  #2  
Old 06-28-2017, 10:39 AM
NoSparks NoSparks is offline VBA code If... then... copy... from one sheet to another Windows 7 64bit VBA code If... then... copy... from one sheet to another Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 831
NoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really nice
Default

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.
Reply With Quote
  #3  
Old 06-28-2017, 10:52 AM
Seiquo Seiquo is offline VBA code If... then... copy... from one sheet to another Windows 7 64bit VBA code If... then... copy... from one sheet to another Office 2010 64bit
Novice
VBA code If... then... copy... from one sheet to another
 
Join Date: Jun 2017
Posts: 4
Seiquo is on a distinguished road
Default

Woooot!

Thank you so much NoSparks!

It really was a Newbie mistake.

Solved.
Reply With Quote
Reply



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
VBA code If... then... copy... from one sheet to another 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

Other Forums: Access Forums

All times are GMT -7. The time now is 01:55 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft