Help with coding...

G

gjfeng

Anyone mind to help me take a look at my code? It's in the nvT Sheet.
I'm getting this:
http://www.geocities.com/gjfeng/no.bmp
the desired outcome is:
http://www.geocities.com/gjfeng/yes.bmp

The part which controls the qty value is:
qty = Worksheets("db").Cells(intRow, 8).Value
'Sheets("nvT").Range("c" & Columns.Count).End(xlUp)(2).Resize(,
1).Value = qty
Worksheets("nvT").Range("IV7", Worksheets("nvT").Cells(7,
Columns.Count).End(xlToLeft))(3).Value = qty

link: http://www.geocities.com/gjfeng/protoV2.xls



Code:
Private Sub CommandButton1_Click()
If Sheets("nvT").Range("b1").Value = "" Then
msgbox "The Date Is Empty!"
Else
Dim box1 As Integer
box1 = msgbox("Ok to Update?", 1 + vbInformation, "Clear Confirm")
If box1 = 1 Then
Dim intRow As Integer
intRow = 2
Do While Worksheets("db").Cells(intRow, 2).Value <> ""
If CStr(Worksheets("db").Cells(intRow, 1).Value) =
Sheets("nvT").Range("b1").Value Then

proID = Worksheets("db").Cells(intRow, 6).Value
pro = Worksheets("db").Cells(intRow, 7).Value
Worksheets("nvT").Range("IV5", Worksheets("nvT").Cells(5,
Columns.Count).End(xlToLeft))(3).Value = proID
Worksheets("nvT").Range("IV6", Worksheets("nvT").Cells(6,
Columns.Count).End(xlToLeft))(3).Value = pro
'Iv5 must match the number 5, IV6 must match the number 6,
they determine the row
'the number in (3), 3 leaves 1 empty space inbetween, 4 leaves
2 empty space

cusID = Worksheets("db").Cells(intRow, 5).Value
cus = Worksheets("db").Cells(intRow, 4).Value
Sheets("nvT").Range("a" & Columns.Count).End(xlUp)(2).Resize(,
2).Value = _
Array(cusID, cus)

qty = Worksheets("db").Cells(intRow, 8).Value
'Sheets("nvT").Range("c" & Columns.Count).End(xlUp)
(2).Resize(, 1).Value = qty
Worksheets("nvT").Range("IV7", Worksheets("nvT").Cells(7,
Columns.Count).End(xlToLeft))(3).Value = qty
End If

intRow = intRow + 1
Loop

Else
End If 'End of Box1
End If 'End of check if empty IF statement

End Sub
Private Sub CommandButton2_Click()
Dim box1 As Integer
box1 = msgbox("Ok to Clear?", 1 + vbExclamation, "Clear Confirm")
If box1 = 1 Then
Worksheets("nvT").Cells.Value = ""
Range("a1").Value = "Order Date"
Range("a2").Value = "Delivery Date"
Range("a3").Value = "Posting Date"
Range("a4").Value = "Unit Price"
Range("a5").Value = "Product ID"
Range("a6").Value = "Product"
Range("c1").Formula = "=IF(B1="""","""",TEXT(WEEKDAY(B1),""ddd""))"
Else
End If

End Sub
Private Sub CommandButton3_Click()
Range("b1").Value = "=TODAY()"
Range("b2").Value = "=TODAY()"
Range("b3").Value = "=TODAY()"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top