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
--
Hope that helps.
Vergel Adriano
"Joe Lee" wrote:
> 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!
|