add border when copy information

Halos

New Member
Joined
Feb 14, 2015
Messages
34
Hi,

Please help how to add border when copying information to the sheet. ( Selection.Borders(xlDiagonalDown).LineStyle = xlNone)

Code:
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
Set ws1 = Worksheets("Sheet2")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row

'copy the data to the database
ws.Cells(iRow, 1).Value = Me.textbox_data.Value
 
Last edited:

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Maybe this

Code:
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
Set ws1 = Worksheets("Sheet2")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row

'copy the data to the database
ws.Cells(iRow, 1).Value = Me.textbox_data.Value

With ws.Cells(iRow, 1).Borders
        .LineStyle = xlContinuous
        .Weight = xlMedium
End With
 
Upvote 0
Maybe this

Code:
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
Set ws1 = Worksheets("Sheet2")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row

'copy the data to the database
ws.Cells(iRow, 1).Value = Me.textbox_data.Value

With ws.Cells(iRow, 1).Borders
        .LineStyle = xlContinuous
        .Weight = xlMedium
End With

ok, thanks but this affects only range but I need full row to be affected?

Code:
Private Sub Cmdbutton_add_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
Set ws1 = Worksheets("Sheet2")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row

With ws.Cells(iRow, 1).Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlMedium
        
         
   
            
        
        
End With
 
Upvote 0
Why not just use conditional formatting within the sheet to add a border where a cell isn't blank?
 
Upvote 0
Ok....you didn't specify the entire row !!!
Try this

Code:
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
Set ws1 = Worksheets("Sheet2")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row

'copy the data to the database
ws.Cells(iRow, 1).Value = Me.textbox_data.Value

With ws.Rows(iRow).Borders
        .LineStyle = xlContinuous
        .Weight = xlMedium
End With
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,197
Members
453,021
Latest member
pingpong7117

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top