Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default adding border from userform

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!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default adding border from userform

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
help with adding list box to userform Chris Excel Programming 2 October 19th 06 03:34 PM
Changing the border of one cell s/n change the border of adjacent gjanssenmn Excel Discussion (Misc queries) 2 October 5th 05 08:35 PM
adding a border in Excel when row is the last one? Rick Excel Discussion (Misc queries) 1 March 23rd 05 03:04 PM
Adding a border to a jpg image bob Excel Programming 1 May 10th 04 11:22 AM
Adding a border to a jpg image Bob Excel Programming 1 May 6th 04 11:53 AM


All times are GMT +1. The time now is 04:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"