adding border from userform

G

Guest

novice here, and i'm having trouble with this one. Quite frustrating for me.

I'm trying to have my userform add borders to the cells with each entry. The
current code looks like this..

Private Sub cmdAdd1_Click()

response = MsgBox("This will add to Project", vbOKCancel)

If response = vbOK Then
Dim LastRow As Object

Set LastRow = Sheet1.Range("a65536").End(xlUp)

LastRow.Offset(1, 3).Value = tbxRequest.Text
LastRow.Offset(1, 5).Value = tbxName.Text
LastRow.Offset(1, 6).Value = tbxDescription.Text
LastRow.Offset(1, 7).Value = tbxRequestor.Text
LastRow.Offset(1, 20).Value = tbxComment.Text
LastRow.Offset(1, 0).Value = cbxIst.Text
LastRow.Offset(1, 2).Value = cbxStatus.Text
LastRow.Offset(1, 1).Value = cbxDemand.Text
LastRow.Offset(1, 8).Value = cbxDepartment.Text
LastRow.Offset(1, 9).Value = tbxLeader.Text


MsgBox "One record written to Project"

response = MsgBox("Do you want to enter another record?", _
vbYesNo)

If response = vbYes Then
tbxRequest.Text = ""
tbxName.Text = ""
tbxDescription.Text = ""
tbxRequestor.Text = ""
tbxComment.Text = ""
tbxLeader.Text = ""
cbxIst.Text = ""
cbxStatus.Text = ""
cbxDemand.Text = ""
cbxDepartment.Text = ""



tbxRequest.SetFocus

Else
Unload Me
End If
Else

End If
End Sub

It finds the next empty row and adds the new entry. I just want to add
borders to that entry and I am quite lost. I've tried the following code but
it just takes way to long everytime it works...

Range("A:U").Select
Selection.borders(xlDiagonalDown).LineStyle = xlNone
Selection.borders(xlDiagonalUp).LineStyle = xlNone
With Selection.borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

help!
 
G

Guest

try adding these lines after you entered the data:

With lastrow.Resize(1, 20)
.BorderAround LineStyle:=xlContinuous, Weight:=xlThin
.Borders(xlInsideVertical).LineStyle = xlContinuous
.Borders(xlInsideVertical).Weight = xlThin
End With
 

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