ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Highlight Range - wrong macro, please edit. (https://www.excelbanter.com/excel-worksheet-functions/51244-highlight-range-wrong-macro-please-edit.html)

Danny

Highlight Range - wrong macro, please edit.
 
Hi,

I got this macro from this NG and I modified it to highlight a range.
However, it's not working. Please help.

Sub BordersBOLD()

Application.Goto Reference:="Applicants"
ActiveCell.Offset(1, 0).Select

With ActiveCell
ilastrow = Cells(Rows.Count, .Column).End(xlDown).Row
Set rng = .Resize(ilastrow - .Row + 1, 9)

'Then I will insert a macro here to make the outline borders bold.

End With
End Sub


Bob Phillips

Highlight Range - wrong macro, please edit.
 
Danny,

In what way does it not work. It seems fine to me, and runs on my system
when I add some border code.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Danny" wrote in message
...
Hi,

I got this macro from this NG and I modified it to highlight a range.
However, it's not working. Please help.

Sub BordersBOLD()

Application.Goto Reference:="Applicants"
ActiveCell.Offset(1, 0).Select

With ActiveCell
ilastrow = Cells(Rows.Count, .Column).End(xlDown).Row
Set rng = .Resize(ilastrow - .Row + 1, 9)

'Then I will insert a macro here to make the outline borders bold.

End With
End Sub




Danny

Highlight Range - wrong macro, please edit.
 
Hi Bob,

I'm glad you responded because it was you that I got the macro. This time, I
modifed the macro to make the outline bold. Originally, when you gave me the
macro, I used it for sorting.

This time, the macro won't highlight the range!

Please help me again.

Thank you.

"Bob Phillips" wrote:

Danny,

In what way does it not work. It seems fine to me, and runs on my system
when I add some border code.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Danny" wrote in message
...
Hi,

I got this macro from this NG and I modified it to highlight a range.
However, it's not working. Please help.

Sub BordersBOLD()

Application.Goto Reference:="Applicants"
ActiveCell.Offset(1, 0).Select

With ActiveCell
ilastrow = Cells(Rows.Count, .Column).End(xlDown).Row
Set rng = .Resize(ilastrow - .Row + 1, 9)

'Then I will insert a macro here to make the outline borders bold.

End With
End Sub





Danny

Highlight Range - wrong macro, please edit.
 
Hi Bob,

It did it again. When you originally gave me the macro, it didn't work. I
re-typed it (not copying from the NG) and it worked. I did the same thing now
and it worked again. There's something wrong with my system.

Sorry,

"Danny" wrote:

Hi Bob,

I'm glad you responded because it was you that I got the macro. This time, I
modifed the macro to make the outline bold. Originally, when you gave me the
macro, I used it for sorting.

This time, the macro won't highlight the range!

Please help me again.

Thank you.

"Bob Phillips" wrote:

Danny,

In what way does it not work. It seems fine to me, and runs on my system
when I add some border code.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Danny" wrote in message
...
Hi,

I got this macro from this NG and I modified it to highlight a range.
However, it's not working. Please help.

Sub BordersBOLD()

Application.Goto Reference:="Applicants"
ActiveCell.Offset(1, 0).Select

With ActiveCell
ilastrow = Cells(Rows.Count, .Column).End(xlDown).Row
Set rng = .Resize(ilastrow - .Row + 1, 9)

'Then I will insert a macro here to make the outline borders bold.

End With
End Sub





Danny

Highlight Range - wrong macro, please edit.
 
Hi,

Now I know what's wrong. below is the complete macro to make the outline bold.


Sub BordersBOLD()

Application.Goto Reference:="Applicants"
ActiveCell.Offset(1, 0).Select

With ActiveCell
ilastrow = Cells(Rows.Count, .Column).End(xlDown).Row
Set rng = .Resize(ilastrow - .Row + 1, 9)


Range("B13:J55").Select

Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.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
End With
End Sub

It only works on 'Range("B13:J55").Select

I was hoping that the macro would find any named range, move down one cell,
resize down to the last cell and 9 columns.

Please help.

"Danny" wrote:

Hi Bob,

It did it again. When you originally gave me the macro, it didn't work. I
re-typed it (not copying from the NG) and it worked. I did the same thing now
and it worked again. There's something wrong with my system.

Sorry,

"Danny" wrote:

Hi Bob,

I'm glad you responded because it was you that I got the macro. This time, I
modifed the macro to make the outline bold. Originally, when you gave me the
macro, I used it for sorting.

This time, the macro won't highlight the range!

Please help me again.

Thank you.

"Bob Phillips" wrote:

Danny,

In what way does it not work. It seems fine to me, and runs on my system
when I add some border code.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Danny" wrote in message
...
Hi,

I got this macro from this NG and I modified it to highlight a range.
However, it's not working. Please help.

Sub BordersBOLD()

Application.Goto Reference:="Applicants"
ActiveCell.Offset(1, 0).Select

With ActiveCell
ilastrow = Cells(Rows.Count, .Column).End(xlDown).Row
Set rng = .Resize(ilastrow - .Row + 1, 9)

'Then I will insert a macro here to make the outline borders bold.

End With
End Sub





Bob Phillips

Highlight Range - wrong macro, please edit.
 
Danny,

Is this what you want?

Sub BordersBOLD()
Dim iLastrow As Long
Dim rng As Range

Application.Goto Reference:="Applicants"
ActiveCell.Offset(1, 0).Select

With ActiveCell
iLastrow = Cells(Rows.Count, .Column).End(xlUp).Row
If iLastrow <= .Row Then Exit Sub
Set rng = .Resize(iLastrow - .Row + 1, 9)
End With

With rng
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
With .Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End With
End Sub



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Danny" wrote in message
...
Hi,

Now I know what's wrong. below is the complete macro to make the outline

bold.


Sub BordersBOLD()

Application.Goto Reference:="Applicants"
ActiveCell.Offset(1, 0).Select

With ActiveCell
ilastrow = Cells(Rows.Count, .Column).End(xlDown).Row
Set rng = .Resize(ilastrow - .Row + 1, 9)


Range("B13:J55").Select

Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.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
End With
End Sub

It only works on 'Range("B13:J55").Select

I was hoping that the macro would find any named range, move down one

cell,
resize down to the last cell and 9 columns.

Please help.

"Danny" wrote:

Hi Bob,

It did it again. When you originally gave me the macro, it didn't work.

I
re-typed it (not copying from the NG) and it worked. I did the same

thing now
and it worked again. There's something wrong with my system.

Sorry,

"Danny" wrote:

Hi Bob,

I'm glad you responded because it was you that I got the macro. This

time, I
modifed the macro to make the outline bold. Originally, when you gave

me the
macro, I used it for sorting.

This time, the macro won't highlight the range!

Please help me again.

Thank you.

"Bob Phillips" wrote:

Danny,

In what way does it not work. It seems fine to me, and runs on my

system
when I add some border code.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Danny" wrote in message
...
Hi,

I got this macro from this NG and I modified it to highlight a

range.
However, it's not working. Please help.

Sub BordersBOLD()

Application.Goto Reference:="Applicants"
ActiveCell.Offset(1, 0).Select

With ActiveCell
ilastrow = Cells(Rows.Count, .Column).End(xlDown).Row
Set rng = .Resize(ilastrow - .Row + 1, 9)

'Then I will insert a macro here to make the outline borders bold.

End With
End Sub







Danny

Highlight Range - wrong macro, please edit.
 
Hi Bob,

There's one minor detail. I have several tables (several references), same
columns, different rows. The tables are separated by one blank row. I was
hoping to run the macro for each table (each table would then be enclosed
with the outline bold border). The macro below highlights all the tables and
the outline border encloses all the tables.

'Application.Goto Reference:="Applicants"
'ActiveCell.Offset(1, 0).Select

What I plan to do is copy the above formula, change the reference (I have 11
tables/references), put in your macro so when I run it, it would make a
border outline for all the tables.

Can you please make the minor adjustments?

Thanks a lot. Have a great day!

"Bob Phillips" wrote:

Danny,

Is this what you want?

Sub BordersBOLD()
Dim iLastrow As Long
Dim rng As Range

Application.Goto Reference:="Applicants"
ActiveCell.Offset(1, 0).Select

With ActiveCell
iLastrow = Cells(Rows.Count, .Column).End(xlUp).Row
If iLastrow <= .Row Then Exit Sub
Set rng = .Resize(iLastrow - .Row + 1, 9)
End With

With rng
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
With .Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End With
End Sub



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Danny" wrote in message
...
Hi,

Now I know what's wrong. below is the complete macro to make the outline

bold.


Sub BordersBOLD()

Application.Goto Reference:="Applicants"
ActiveCell.Offset(1, 0).Select

With ActiveCell
ilastrow = Cells(Rows.Count, .Column).End(xlDown).Row
Set rng = .Resize(ilastrow - .Row + 1, 9)


Range("B13:J55").Select

Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.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
End With
End Sub

It only works on 'Range("B13:J55").Select

I was hoping that the macro would find any named range, move down one

cell,
resize down to the last cell and 9 columns.

Please help.

"Danny" wrote:

Hi Bob,

It did it again. When you originally gave me the macro, it didn't work.

I
re-typed it (not copying from the NG) and it worked. I did the same

thing now
and it worked again. There's something wrong with my system.

Sorry,

"Danny" wrote:

Hi Bob,

I'm glad you responded because it was you that I got the macro. This

time, I
modifed the macro to make the outline bold. Originally, when you gave

me the
macro, I used it for sorting.

This time, the macro won't highlight the range!

Please help me again.

Thank you.

"Bob Phillips" wrote:

Danny,

In what way does it not work. It seems fine to me, and runs on my

system
when I add some border code.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Danny" wrote in message
...
Hi,

I got this macro from this NG and I modified it to highlight a

range.
However, it's not working. Please help.

Sub BordersBOLD()

Application.Goto Reference:="Applicants"
ActiveCell.Offset(1, 0).Select

With ActiveCell
ilastrow = Cells(Rows.Count, .Column).End(xlDown).Row
Set rng = .Resize(ilastrow - .Row + 1, 9)

'Then I will insert a macro here to make the outline borders bold.

End With
End Sub








Bob Phillips

Highlight Range - wrong macro, please edit.
 
Danny,

I hope I have correctly interpreted this


Sub ApplyBorders()
BordersBOLD "Applicants"
BordersBOLD "Another"
BordersBOLD "SomeOther"
'etc.
End Sub


Sub BordersBOLD(tablename As String)
Dim iLastrow As Long
Dim rng As Range

Application.Goto Reference:=tablename
ActiveCell.Offset(1, 0).Select

With ActiveCell
iLastrow = Cells(Rows.Count, .Column).End(xlUp).Row
If iLastrow <= .Row Then Exit Sub
Set rng = .Resize(iLastrow - .Row + 1, 9)
End With

With rng
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
With .Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End With
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Danny" wrote in message
...
Hi Bob,

There's one minor detail. I have several tables (several references), same
columns, different rows. The tables are separated by one blank row. I was
hoping to run the macro for each table (each table would then be enclosed
with the outline bold border). The macro below highlights all the tables

and
the outline border encloses all the tables.

'Application.Goto Reference:="Applicants"
'ActiveCell.Offset(1, 0).Select

What I plan to do is copy the above formula, change the reference (I have

11
tables/references), put in your macro so when I run it, it would make a
border outline for all the tables.

Can you please make the minor adjustments?

Thanks a lot. Have a great day!

"Bob Phillips" wrote:

Danny,

Is this what you want?

Sub BordersBOLD()
Dim iLastrow As Long
Dim rng As Range

Application.Goto Reference:="Applicants"
ActiveCell.Offset(1, 0).Select

With ActiveCell
iLastrow = Cells(Rows.Count, .Column).End(xlUp).Row
If iLastrow <= .Row Then Exit Sub
Set rng = .Resize(iLastrow - .Row + 1, 9)
End With

With rng
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
With .Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End With
End Sub



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Danny" wrote in message
...
Hi,

Now I know what's wrong. below is the complete macro to make the

outline
bold.


Sub BordersBOLD()

Application.Goto Reference:="Applicants"
ActiveCell.Offset(1, 0).Select

With ActiveCell
ilastrow = Cells(Rows.Count, .Column).End(xlDown).Row
Set rng = .Resize(ilastrow - .Row + 1, 9)


Range("B13:J55").Select

Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.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
End With
End Sub

It only works on 'Range("B13:J55").Select

I was hoping that the macro would find any named range, move down one

cell,
resize down to the last cell and 9 columns.

Please help.

"Danny" wrote:

Hi Bob,

It did it again. When you originally gave me the macro, it didn't

work.
I
re-typed it (not copying from the NG) and it worked. I did the same

thing now
and it worked again. There's something wrong with my system.

Sorry,

"Danny" wrote:

Hi Bob,

I'm glad you responded because it was you that I got the macro.

This
time, I
modifed the macro to make the outline bold. Originally, when you

gave
me the
macro, I used it for sorting.

This time, the macro won't highlight the range!

Please help me again.

Thank you.

"Bob Phillips" wrote:

Danny,

In what way does it not work. It seems fine to me, and runs on

my
system
when I add some border code.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Danny" wrote in message
...
Hi,

I got this macro from this NG and I modified it to highlight a

range.
However, it's not working. Please help.

Sub BordersBOLD()

Application.Goto Reference:="Applicants"
ActiveCell.Offset(1, 0).Select

With ActiveCell
ilastrow = Cells(Rows.Count, .Column).End(xlDown).Row
Set rng = .Resize(ilastrow - .Row + 1, 9)

'Then I will insert a macro here to make the outline borders

bold.

End With
End Sub










Danny

Highlight Range - wrong macro, please edit.
 
Hi Bob,

Maybe I'm not communicating my problem properly. I already wasted a lot of
your precious time. What if we simply it to:

Sub BordersBOLD()
'Application.Goto Reference:="Applicants"
ActiveCell.Offset(1, 0).Select

Macro to resize equivalent to:

"Selection.resize(xldown,7).Select"

If only the above macro would work! But the "xldown" portion of it will not.

Then macro to outline for the bold borders. I can use this individually for
each table.

I now I realize that I kept on using the word "table" and you made a macro
for it (thank you very much). Now I'm certain that I am not communicating
propery.

In my worksheet I sort them according to codes (1 to 11) then, I separate
them by groups (separated by a blank row).

Each group (the table I was referring to, no name) Col A=the code, Col B=the
name of the group, i.e., "applicants". That's why the reference is
"Applicants" then go down one cell "ActiveCell.Offset(1, 0).Select"

then resize to highlight down to the last row of the group. The RESIZING AND
HIGHLIGTING is whre the problem is.

I don't mind running the macro for each reference.

By the way, all the macros on this worksheet was provided by this NG with
VERY HELPFUL individuals like yourself.

Have a great day!








"Bob Phillips" wrote:

Danny,

I hope I have correctly interpreted this


Sub ApplyBorders()
BordersBOLD "Applicants"
BordersBOLD "Another"
BordersBOLD "SomeOther"
'etc.
End Sub


Sub BordersBOLD(tablename As String)
Dim iLastrow As Long
Dim rng As Range

Application.Goto Reference:=tablename
ActiveCell.Offset(1, 0).Select

With ActiveCell
iLastrow = Cells(Rows.Count, .Column).End(xlUp).Row
If iLastrow <= .Row Then Exit Sub
Set rng = .Resize(iLastrow - .Row + 1, 9)
End With

With rng
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
With .Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End With
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Danny" wrote in message
...
Hi Bob,

There's one minor detail. I have several tables (several references), same
columns, different rows. The tables are separated by one blank row. I was
hoping to run the macro for each table (each table would then be enclosed
with the outline bold border). The macro below highlights all the tables

and
the outline border encloses all the tables.

'Application.Goto Reference:="Applicants"
'ActiveCell.Offset(1, 0).Select

What I plan to do is copy the above formula, change the reference (I have

11
tables/references), put in your macro so when I run it, it would make a
border outline for all the tables.

Can you please make the minor adjustments?

Thanks a lot. Have a great day!

"Bob Phillips" wrote:

Danny,

Is this what you want?

Sub BordersBOLD()
Dim iLastrow As Long
Dim rng As Range

Application.Goto Reference:="Applicants"
ActiveCell.Offset(1, 0).Select

With ActiveCell
iLastrow = Cells(Rows.Count, .Column).End(xlUp).Row
If iLastrow <= .Row Then Exit Sub
Set rng = .Resize(iLastrow - .Row + 1, 9)
End With

With rng
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
With .Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With .Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End With
End Sub



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Danny" wrote in message
...
Hi,

Now I know what's wrong. below is the complete macro to make the

outline
bold.


Sub BordersBOLD()

Application.Goto Reference:="Applicants"
ActiveCell.Offset(1, 0).Select

With ActiveCell
ilastrow = Cells(Rows.Count, .Column).End(xlDown).Row
Set rng = .Resize(ilastrow - .Row + 1, 9)


Range("B13:J55").Select

Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.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
End With
End Sub

It only works on 'Range("B13:J55").Select

I was hoping that the macro would find any named range, move down one
cell,
resize down to the last cell and 9 columns.

Please help.

"Danny" wrote:

Hi Bob,

It did it again. When you originally gave me the macro, it didn't

work.
I
re-typed it (not copying from the NG) and it worked. I did the same
thing now
and it worked again. There's something wrong with my system.

Sorry,

"Danny" wrote:

Hi Bob,

I'm glad you responded because it was you that I got the macro.

This
time, I
modifed the macro to make the outline bold. Originally, when you

gave
me the
macro, I used it for sorting.

This time, the macro won't highlight the range!

Please help me again.

Thank you.

"Bob Phillips" wrote:

Danny,

In what way does it not work. It seems fine to me, and runs on

my
system
when I add some border code.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Danny" wrote in message
...
Hi,

I got this macro from this NG and I modified it to highlight a
range.
However, it's not working. Please help.

Sub BordersBOLD()

Application.Goto Reference:="Applicants"
ActiveCell.Offset(1, 0).Select

With ActiveCell
ilastrow = Cells(Rows.Count, .Column).End(xlDown).Row
Set rng = .Resize(ilastrow - .Row + 1, 9)

'Then I will insert a macro here to make the outline borders

bold.

End With
End Sub









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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com