excel vba compile error on year function -
I am writing VBA sub-routine in Excel VBA which is the amount of LBS sold to customers for different years and any The reason is a compilation error with the year celebration. Can someone please explain this? Here is my code:
Private sub lbsPerCustPerYear_Click () I dim the integer dim client as string dim Cust2 string dim sum as integer dim output range Dim Output2 as the range dims YEAR1 In the form of total date = 0 as in the form of YEAR1 = range ("K6"). Price Clients = Range ("C6") Price Cust2 = Range ("C7"). Value set output = sheet ("Sheet2"). Cells (2, 2) set Output2 = Sheets ("Sheet2"). For cells (2, 3) I = 1 to 14750 years 1 = range ("of 5") offsets (i, 0). If the value is (sheet ("sheet 1"). Cells (i, 11 (),) if the total = range ("Q5"). Offset (I, 0). Value + range ("Q6") .Offset I, 0) .Value Customer = Range ("C5"). Offset (i, 0) .Value Cust2 = Range ("C6"). (Offset I, 0) .Value Output.Value = Customer Output2 .Value = Total or Customer = range ("C5"). Offset (i, 0) .Value Cust2 = Range ("C6"). Offset (i, 0) .Value YEAR1 = Range ("K5"). Offset ( I, 0) .value set output = Output.Offset (1, 0) Set Output2 = Output2.Offset (1, 0) If not, then end the customer = range ("C5"). Offset (i, 0). Value Cust2 = Range ("C6") Offset (i, 0 ) .Value YEAR1 = Range ("K5"). Offset (i, 0) .Value Set Output = Output.Offset (1, 0) Set Output2 = Output2.Offset (1, 0) End if Next I End Sub
The error is in the line:
if cut = cut 2 and year (sheets ("sheet 1"). Cell (i, 11). Value) = 2012 again
Thanks in advance!
Whether each column 11 Is there a valid date or year in the room?
You can check it first:
if incoming (sheet ("Sheet1") .mail (i, 11). Value) then if cut = CUSTOM 2 and year (Sheets ("Sheet1"). Room (i, 11). Value) = 2012 then ...... finally if the 'invalid date end if
I have seen that there is something else, you have used the year as a variable name, convert it to DTear or something as it can be contradictory with the year function in the object library.
Comments
Post a Comment