Easy Macro Problem

Big Tom

New Member
Joined
Apr 11, 2002
Messages
5
I really really want to know how to propagate a macro from one area to another - if that makes sense...
A simply example: While recording a macro, if i select a line from col B to J, and then turn it bold, how can i write the cell refs so that this simple operation repeats to the next line each time i run the macro (eg by pressing my shortcut key).
Or, if my cursor has highlighted the cell in column A, with my macro i want to select and underline the rest of the row (to J) - but then i want to select another line and have the macro underline this new line and not automatically go back to the original line. Understand????
please help - its driving me mad
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
ok ok... a for loop. no i don't know VB but that sounds very useful. i'll try to find it. Thanks alot
 
Upvote 0
No problem. A for loop just loops a set of code a designated amount of times and then ends. Each time the code loops it can change a value in the set of code, say for you you would change the cell range. Ie if you wanted to go down the cell column you would go A1 (first loop) A2 (second loop) etc
 
Upvote 0
what i really want to do is have a macro that performs a set of operations on a range of columns in a row and where it doesn't matter what row you've initially selected, be it 1, 15 or 1394.
I need it to ,say, turn it bold or underline it or (for a range) sort it or run a more complex macro on it.
can i not simply write the cell/column syntax slightly differently - like R3C29 or $J$89 or something like that??
sorry to go on, but the rows i need to treat are irregularly spaced out over several thousand lines and maybe a loop might not work?? i'm not sure..
 
Upvote 0
This does something similar. It changes the colour of the cell to Red, but it only does this for one cell.

If anyone know how to change this so that it does it for multiple cells along a row (say the first 10), I would like to know how to do that.

Thanks

Sub red()
'
' red Macro
' Keyboard Shortcut: Ctrl+r
'
Dim i As Integer
For i = 1 To 10

With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With

Next i

End Sub
 
Upvote 0
Try the format painter (the little paintbrush) Just put the cellpointer on the cell with the format you want and double click on the paintbrush. Any cell you then click on will duplicate the format in the original cell. Click Esc to abort.
This will work for multiple cells also. Just highlight the row you want.
Good luck
 
Upvote 0
Not sure if I have read it wrong, or if everyone has else has, but try this;

Sub Make_a_j_bold ()

ActiveCell.Range("A1:J1").Select
Selection.Font.Bold = True
Selection.End(xlToLeft).Select

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,572
Messages
6,120,306
Members
448,955
Latest member
Dreamz high

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