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

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
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,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

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