Easy Macro Problem
Easy Macro Problem
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 9 of 9

Thread: Easy Macro Problem

  1. #1
    New Member
    Join Date
    Apr 2002
    Posts
    5
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    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

  2. #2
    Board Regular
    Join Date
    Apr 2002
    Location
    Australia
    Posts
    52
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    If you know VB you can use a "For loop". Iterating line by line.

  3. #3
    New Member
    Join Date
    Apr 2002
    Posts
    5
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    ok ok... a for loop. no i don't know VB but that sounds very useful. i'll try to find it. Thanks alot

  4. #4
    New Member
    Join Date
    Apr 2002
    Posts
    5
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    actually, i have no idea how to do that... any clues?

  5. #5
    Board Regular
    Join Date
    Apr 2002
    Location
    Australia
    Posts
    52
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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

  6. #6
    New Member
    Join Date
    Apr 2002
    Posts
    5
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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..

  7. #7
    New Member
    Join Date
    Apr 2002
    Location
    this_me_
    Posts
    1
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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

  8. #8
    Board Regular
    Join Date
    Feb 2002
    Location
    Las Vegas Nevada USA
    Posts
    239
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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
    George

    Learn to listen. Opportunity sometimes knocks very softly.

  9. #9
    Board Regular
    Join Date
    Apr 2002
    Posts
    2,314
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    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

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com