Question

Locked

Visual Basic Help

By awillman ·
If there's anyone out there who could hep me with Visual Basic, I'm trying to program a macro that records the current date (for checking in a laptop that has been checked out) in excel. I've gotten the button to bring up a window with bubble selections for each laptop and projector that we have with a check in button and a cancel button. The cancel button works (no biggie) but I can't get it to enter in the date to the corresponding checked out piece of equipment. Keeping in mind, I have never even screwed around with Visual Basic until yesterday, so I'm just getting severely frustrated instead of progressing further.

Thanks!
Alex

This conversation is currently closed to new comments.

6 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Can you post your code?

by cmiller5400 In reply to Visual Basic Help

That would help us help you. I can't read minds... Yet.

Collapse -

Don't think the code is gonna help, but here it is.

by awillman In reply to Can you post your code?

Remember, this is day 2 of me using VB, so yeah. Try not to laugh.

Private Sub CheckinButton_Click()

ActiveWorkbook.Sheets("Laptop Checkout").Activate

Range("A1").Select

Do

If IsEmpty(ActiveCell) = False Then

If Floater1 = yes Then

ActiveCell.Offset(0, 7).Select

End If

IsEmpty(ActiveCell) = True

ActiveCell.Value = Date

ActiveCell.Offset(0, 7) = Date



End Sub

Private Sub cmdCancel_Click()
Unload Me
End Sub

Collapse -

Checkout Code, if it'll help.

by awillman In reply to Can you post your code?

Private Sub cmdCancel_Click()
Unload Me
End Sub

Private Sub cmdClearForm_Click()
Call UserForm_Initialize
End Sub

Private Sub cmdOK_Click()

ActiveWorkbook.Sheets("Laptop Checkout").Activate

Range("A1").Select

Do

If IsEmpty(ActiveCell) = False Then

ActiveCell.Offset(1, 0).Select

End If

Loop Until IsEmpty(ActiveCell) = True

ActiveCell.Value = txtName.Value

ActiveCell.Offset(0, 1) = txtDepartment.Value

ActiveCell.Offset(0, 2) = txtPhone.Value

ActiveCell.Offset(0, 3) = txtCheckout.Value

ActiveCell.Offset(0, 4) = txtReturn.Value

ActiveCell.Offset(0, 5) = txtBrand.Value

ActiveCell.Offset(0, 6) = txtModel.Value


If chkLaptop = True Then
ActiveCell.Offset(0, 9).Value = "Yes"
Else
ActiveCell.Offset(0, 9).Value = "No"
End If

If chkPower = True Then
ActiveCell.Offset(0, 10).Value = "Yes"
Else
ActiveCell.Offset(0, 10).Value = "No"
End If

If chkModem = True Then
ActiveCell.Offset(0, 11).Value = "Yes"
Else
ActiveCell.Offset(0, 11).Value = "No"
End If

If chkFloppy = True Then
ActiveCell.Offset(0, 12).Value = "Yes"
Else
ActiveCell.Offset(0, 12).Value = "No"
End If

If chkMouse = True Then
ActiveCell.Offset(0, 13).Value = "Yes"
Else
ActiveCell.Offset(0, 13).Value = "No"
End If

If chkSpare = True Then
ActiveCell.Offset(0, 14).Value = "Yes"
Else
ActiveCell.Offset(0, 14).Value = "No"
End If

If chkNetwork = True Then
ActiveCell.Offset(0, 15).Value = "Yes"
Else
ActiveCell.Offset(0, 15).Value = "No"
End If

If chkCD = True Then
ActiveCell.Offset(0, 16).Value = "Yes"
Else
ActiveCell.Offset(0, 16).Value = "No"
End If

If chkOther = True Then
ActiveCell.Offset(0, 17).Value = "Yes"
Else
ActiveCell.Offset(0, 17).Value = "No"
End If


ActiveCell.Offset(0, 1 = txtOther.Value

Call UserForm_Initialize

Range("A1").Select

End Sub

Private Sub Label6_Click()

End Sub

Private Sub UserForm_Initialize()

txtName.Value = ""
txtDepartment.Value = ""
txtPhone.Value = ""
txtCheckout.Value = Date
txtReturn.Value = ""
txtBrand.Value = ""
txtModel.Value = ""


chkLaptop = False
chkPower = False
chkModem = False
chkFloppy = False
chkMouse = False
chkSpare = False
chkNetwork = False
chkCD = False
chkOther = False

txtOther.Value = ""

End Sub

Collapse -

This might give you a hint........

by ThumbsUp2 In reply to Visual Basic Help

Since, in Excel, today's date is input by typing =today() ... the code in a simple macro to select the cell and input today's date would be:

Range("C3").Select
ActiveCell.FormulaR1C1 = "=TODAY()"


------

So, see if you can incorporate that into your existing code.

Collapse -

Column H

by awillman In reply to This might give you a hin ...

My dates will be in column H.

How should that formula look?

Back to Software Forum
6 total posts (Page 1 of 1)  

Related Discussions

Related Forums