Change "borders" through VBA code

James

Active Member
Joined
Feb 17, 2002
Messages
327
Hi group,

I'm trying to with a commmandbutton
search cells Q6:Q1000 and find the cells that are formatted as accounting with the $ symbol
and change the "borders" to Selection.Borders
(xlEdgeBotton).Linestyle = xlNone

Any help would be appreciated
James
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
try this ;-

Dim rng1 As Range, rng2 As Range
Application.ScreenUpdating = False
Columns("Q:Q").Insert
Set rng1 = [Q6:Q1000]
rng1.FormulaR1C1 = "=IF(CELL(""format"",RC[1])=""C2"",1,"""")"
On Error GoTo e
Set rng2 = rng1.SpecialCells(xlCellTypeFormulas, 1)
With rng2.Offset(0, 1)
.Borders(xlEdgeBottom).LineStyle = xlNone
.Borders(xlInsideHorizontal).LineStyle = xlNone
End With
e:
On Error GoTo 0
Columns("Q:Q").Delete


cojones
This message was edited by C. O. Jones on 2002-03-31 18:39
This message was edited by C. O. Jones on 2002-03-31 18:39
 
Upvote 0
On 2002-03-31 17:28, James wrote:
Hi group,

I'm trying to with a commmandbutton
search cells Q6:Q1000 and find the cells that are formatted as accounting with the $ symbol
and change the "borders" to Selection.Borders
(xlEdgeBotton).Linestyle = xlNone

Any help would be appreciated
James

James try something like this;

<pre/>
Sub Macro1()
Dim MyRg As Range
Dim oCell As Range

Set MyRg = Range("Q6:Q1000")
On Error Resume Next
Set MyRg = Application.Union(MyRg.SpecialCells(xlCellTypeFormulas, 1), _
MyRg.SpecialCells(xlCellTypeConstants, 1))
If Err Then MsgBox "No Data Cells": End

For Each oCell In MyRg
If oCell.Style = "Currency" Then
With oCell.Borders(9)
.LineStyle = xlNone
End With
End If
Next

Set MyRg = Nothing

End Sub

</pre>
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,449
Members
448,966
Latest member
DannyC96

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