Results 1 to 4 of 4

Thread: [RESOLVED] How to create an Excel Macro for adding text in multiple cells

  1. #1
    New Member
    Join Date
    Sep 12
    Posts
    3

    Resolved [RESOLVED] How to create an Excel Macro for adding text in multiple cells

    How do I create a MS Excel Macro that will copy and paste <p> </p> tags in multiple cells within the same column around paragraphs?

    Example:

    Column B Cell 1:

    <p>This is a paragraph that is going to be used in this post as an example. Place the paragraph tags around this.</p>

    Column B Cell 2:

    <p>This is a paragraph with text used for an example.</p>

    And so on.

    Paragraphs such as these are in multiple cells within Column B. About 426 cells.

  2. #2
    PowerPoster
    Join Date
    Dec 04
    Posts
    18,526

    Re: How to create an Excel Macro for adding text in multiple cells

    try like
    Code:
    for each cel in range("b:b")
      if isempty(cel) then exit for  ' end on empty cel
      cel.value = "<p>" & cel & "</p>"
    next
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3
    New Member
    Join Date
    Sep 12
    Posts
    3

    Re: How to create an Excel Macro for adding text in multiple cells

    Okay. Thank you. I will give it a try. Do you know any good references for creating these type of macros?

  4. #4
    New Member
    Join Date
    Sep 12
    Posts
    3

    Re: [RESOLVED] How to create an Excel Macro for adding text in multiple cells

    Thank you. Your code worked today.

Posting Permissions

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