+ Reply to Thread
Results 1 to 4 of 4

Macro to address cells in the next column to selection

  1. #1
    Registered User
    Join Date
    05-16-2008
    Posts
    7

    Macro to address cells in the next column to selection

    Hi All,

    Newbie to this site.

    I must say that I've always found help forums to be amazing places, and I never fail to get useful advice. To this end I have TWO MACRO QUESTIONS:

    QUESTION 1.
    I work on a cruise ship as a musician and recently helped out the admin office with a simple macro used on their daily planner. Effectively, we start with a blank timesheet where each cell=quarter hour and all cells are shaded grey. The macro merges the selected cells (eg 4 contiguous cells at A1, A2, A3 and A4; representing an hour to be worked by my band), makes them all white, removes the dividing lines, centres the text and applies a thick black border around the selection. I used MacroRecorder to create this, as my programming knowledge stopped at ANSI Basic and a bit of COBOL!

    There is a further requirement which I hope you can help me with. For each cell selected and, errr, macro-ed (?), there needs to be a corresponding value of 0.25 put in the cell to the immediate right. This is for a head office requirement where hours worked (in quarter hour intervals, hence 0.25) need to be totaled in a separate column. I created another simple macro whereby all cells selected are filled with the correct value, but there must be some way to do this in ONE macro. Is there any way to reference the top cell of the selection (in my example A1) and the bottom cell of the selection (in my example A4, but this could be A5, A6……… Ann for longer work periods) and then fill ALL cells to the right (ie within the corresponding B column cells) with the value 0.25?

    I’m sure this has something to do with Relative cell addressing, ranges and for…next loops, but as I’m on a ship I have limited access to the internet and therefore cannot trawl through all the Visual Basic sites until I find the answer. I’d appreciate someone completing the macro for me and tidying up the unnecessary lines which I’m sure are there! Also, if possible, could you explain in semi-layman’s terms why you’ve done what you’ve done, so I could try to understand the logic behind the coding.

    Here’s the macro as recorded by MacroRecorder:


    Please Login or Register  to view this content.
    QUESTION 2.
    I need to be able to copy and paste a range of cells (containing pictures and heavily formatted text) from one spreadsheet into another. Lets assume this is in a worksheet called ‘SOURCESHEET’ and the range is A1:E1 (ie 5 cells across, 1 cell deep.) I’d like to do this by creating a macro which selects a range of cells of the same area based on the currently selected cell (ie if I select A3 then the macro needs to know it’s working in the area A3:E3), resizes the depth of these cells to the same depth as the cells in SOURCESHEET, then inserts the picture/text cells at that point. Also, parts of A1:E1 have been merged, so the macro would have to format the destination area accordingly before the pictures/text can be inserted (I say this as I assume that there will be errors if I try to paste a 3-cell source across a 5-cell range). The pictures and text would need to be embedded into DESTINATIONSHEET, as the SOURCESHEET is held locally wheras DESTINATIONSHEET will be a network document that needs to be printed at various locations.

    Am I right in assuming that there is a ‘copy source format’ function which will take care of the merging/re-sizing requirements, or is there another way round this?


    Well, if you’ve read this far then hopefully you’re up for the challenge, so I thank you in advance and look forward to your reply.

    Regards,

    Miles_muso,
    Musician on P&O Cruise ship
    And reluctant ‘expert’ on computers (ie the only one who even knows what a macro is!)
    Last edited by miles_muso; 05-16-2008 at 07:23 AM. Reason: instruction from forum admin - wrong format

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    miles_muso

    Welcome to Exceltip forum

    Please take a couple of minutes and read the Forum Rules then edit your thread title by following the instructions in the rules (Rule 1)

    and wrap your VBA code (Rule 3)
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  3. #3
    Registered User
    Join Date
    05-16-2008
    Posts
    7

    Red face Thanks to admin

    Hi Mudraker,

    Many thanks for your instructions on the correct format for posts to this forum. I have edited accordingly.

    miles_muso

  4. #4
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Thanks for fixing your thread errors


    For Question 1

    Add this command after the last End With & before the End Sub of your macro

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1