formating macro

G

Guest

Hi,
I have problem in macro codes.
I have recorded macro for rows formatting. For recording a macro I have
chosen line no.22.
After recording a macro I want to run this in line different rows, say for
example line no. 50. But whenever I run this It will go to line no.22 and
formatting.
How to change macro codes….I don’t want to give particular cell number in
macro codes.
I want to run this in different cells every time.
Please advise me…?

Regards,
Vishu
 
G

Gord Dibben

Vishu

With ActiveCell

..EntireRow.Interior.ColorIndex = 6

End With


Gord Dibben Excel MVP
 
G

Guest

Hi Don,
Can you help me to change this macro codes:

Sub formating()
Rows("10:10").Select
Range("B10").Activate
Selection.RowHeight = 19
Range("B10:K10").Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Selection.Interior.ColorIndex = 36
Range("L10:O10").Select
With Selection.Interior
.ColorIndex = 40
.Pattern = xlSolid
End With
Range("P10:Q10").Select
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
Range("Q10").Select
Range(Selection, Selection.End(xlToLeft)).Select
Rows("10:10").Select
Range("Q10").Activate
With Selection.Font
.Name = "Tahoma"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("B10:Q10").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 15
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 15
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 15
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 15
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 15
End With
End Sub


I want to run this macro in different rows. please help me.
regards
vishu
 
D

Don Guillett

use this idea, in a regular module, to run from anywhere in the workbook.
Don't forget the .'s

with sheets("sheet1").range("b10:q10")
..RowHeight = 19
..Interior.ColorIndex = 40
..Borders.LineStyle = xlContinuous
..Borders.Weight = xlMedium
'.you get the idea
end with
 
G

Guest

Hi Don,
You are refering particular cell number i.e., B10:Q10.
I dont want to run this formating macro in any one particular Cell.
I want to run this in any rows. It can be B1:Q10, or B98:Q98 or B1001:Q1001.
In otherwords I want run in in relative references but not absolute
references.
 
D

Don Guillett

with sheets("sheet1").range("b10:q10")
with selection
or insert your own variable
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top