PC Review


Reply
Thread Tools Rate Thread

adding border from userform

 
 
=?Utf-8?B?Sm9lIExlZQ==?=
Guest
Posts: n/a
 
      5th Sep 2007
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!
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VmVyZ2VsIEFkcmlhbm8=?=
Guest
Posts: n/a
 
      5th Sep 2007
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!

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Userform without title or border... SpeeD Microsoft Excel Programming 9 27th Oct 2009 12:05 AM
Userform loading, but Content (Inside border) is BLANK? JMay Microsoft Excel Programming 1 5th Mar 2009 03:38 PM
Adding border buttons =?Utf-8?B?SXJpc1Jvc2U=?= Microsoft Frontpage 5 6th May 2005 03:36 PM
Body of page appears in Top Border, Left Border and Bottom Border (there is no right border) Michael Edwards Microsoft Frontpage 1 14th Oct 2004 09:46 AM
Adding a border to a jpg image bob Microsoft Excel Programming 1 10th May 2004 11:22 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:25 AM.