Can't get this if statements right

Guanjin Peter

Active Member
Joined
May 21, 2008
Messages
429
**nevermind my question...it woun't help if if I put 2 IFs together**

I want to modify the below code to check for a matches.
If sh.cells(intRow,10).value = worksheets("sheet1").cells(3,11).value
which is a string value
AND
if
'If CStr(Sh.Cells(intRow, 1).Value) = Worksheets("Sheet1").Cells(3, 2).Value
which is a date value

Code:
Do While Sh.Cells(intRow, 5).Value <> ""
If CStr(Sh.Cells(intRow, 10).Value) = Worksheets("Sheet1").Cells(3, 11).Value Then
'If CStr(Sh.Cells(intRow, 1).Value) = Worksheets("Sheet1").Cells(3, 2).Value Then
Worksheets("Sheet1").Range("a3") = "Date"
Worksheets("Sheet1").Range("a4") = "Area"
Worksheets("Sheet1").Range("j3") = "Driver"
Worksheets("Sheet1").Range("j4") = "Vehicle"
Worksheets("Sheet1").Range("a5") = " "
Worksheets("Sheet1").Range("a6") = "S/NO"
Worksheets("Sheet1").Range("b5") = " "
Worksheets("Sheet1").Range("b6") = "CustID"
Worksheets("Sheet1").Range("c5") = " "
Worksheets("Sheet1").Range("c6") = "Customer"
Worksheets("Sheet1").Range("d5") = " "
Worksheets("Sheet1").Range("d6") = "Invoice"
Worksheets("Sheet1").Range("e5") = " "
Worksheets("Sheet1").Range("e6") = "Remarks"
    proid = Sh.Cells(intRow, 6).Value
    pro = Sh.Cells(intRow, 7).Value
    Set rProd = Worksheets("Sheet1").Cells(5, Columns.count).End(xlToLeft)
    rProd.Offset(0, 1).Value = proid
    rProd.Offset(1, 1).Value = pro
    custID = Sh.Cells(intRow, 4).Value
    cust = Sh.Cells(intRow, 5).Value
    Set rCust = Worksheets("Sheet1").Range("b" & Columns.count).End(xlUp)
    rCust.Offset(1, 0).Resize(, 2) = Array(cust, custID)
    qty = Sh.Cells(intRow, 8).Value
    Worksheets("Sheet1").Cells(rCust.Row + 1, rProd.Column + 1).Value = qty 'Cells(,start at which column?)
 
           End If
    'End If
            intRow = intRow + 1
        Loop
 
Last edited:

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Guanjin Peter

Active Member
Joined
May 21, 2008
Messages
429
sorry for the trouble. I know what I really want:
As you can see from the code it only shows the data that matches the name (string value) only

I want an additional condition. It only shows the data that matches the name(string) and the date(date)
 

Watch MrExcel Video

Forum statistics

Threads
1,130,342
Messages
5,641,592
Members
417,224
Latest member
llama9207

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
Top