Consulting

Results 1 to 9 of 9

Thread: Formatting not alligning properly on macro run

  1. #1

    Formatting not alligning properly on macro run

    I have modified the excellet code provided in this forum from a recent post (My current count will not let me add link).

    I think I have edited all the appropriate ranges but I'm obviously missing something and cannot figure out why it will not allign properly when running the macro.

    Thank you in advance for any assistance.

    BigDawg15


    Create Calendar - Shade - Copy - Copy.xls

  2. #2
    VBAX Regular
    Joined
    Feb 2012
    Posts
    31
    Location
    What exactly are you trying to do?
    ------------------------------------------------

    Thanks For All Your Help

    Windows 7

    Excel 2010

    Any codes I provide please try on a copy of your workbook first as these cannot be undone!

    To get the most precise answer, it is best to upload/attach a sample workbook (sensitive data scrubbed/removed/changed) that contains an example of your raw data on one worksheet, and on another worksheet your desired results.

    The structure and data types of the sample workbook must exactly duplicate the real workbook. Include a clear and explicit explanation of your requirements.

  3. #3
    dazwm,

    Thank you for your reply. When the macro is run it currently creates calendars according to the date entered, however the day and date columns are not alligned with the name columns (run the macro and you will see what I mean).

    I have modified the macros which were found in these forums, but I am missing something that is throwing off the allignment.

    I am open to any suggestions to consolidate or to a better way of doing it, I am just working with what I have.

    Thank you again for your time,

    BigDawg15

  4. #4
    VBAX Regular
    Joined
    Feb 2012
    Posts
    31
    Location
    I am not sure I understand what you mean, but you could add something like below at the end of your code

    Cells.Select
        Cells.EntireColumn.AutoFit
    ------------------------------------------------

    Thanks For All Your Help

    Windows 7

    Excel 2010

    Any codes I provide please try on a copy of your workbook first as these cannot be undone!

    To get the most precise answer, it is best to upload/attach a sample workbook (sensitive data scrubbed/removed/changed) that contains an example of your raw data on one worksheet, and on another worksheet your desired results.

    The structure and data types of the sample workbook must exactly duplicate the real workbook. Include a clear and explicit explanation of your requirements.

  5. #5
    dazwm,

    Sorry if I am not explaining this clearly. Lets say in A2 is the name Joe. In D1 is Sun and D2 1 (the first day of the month). When the macro is run to create the new calendar, Sun and 1 are created four or five rows down rather than in D1 and D2 as they should be.

    I hope that is a bit clearer.

    BigDawg15

  6. #6
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,727
    Location
    however the day and date columns are not alligned with the name columns
    I'm not sure what you mean by 'not aligned'

    If you mean the vertical alignment of the Col A cells, they are Aligned Bottom, and the Day/Date are Aligned Center

    Just put something like this in
    [vba]
    With Range("A:A")
    .VerticalAlignment = xlCenter
    End With
    [/vba]

    Otherwise, some more details


    Lets say in A2 is the name Joe.
    I'd have thought that Joe would go in A5, Tom in A6, Mary in A7, etc.

    Paul
    Attached Images Attached Images

  7. #7
    Paul,

    Thank you for the reply. You are correct in how the names are listed in column A. I understand the allignment of text, that is not the problem. When the macro is run, the day and dates from rows d23:ah24 are moved down to rows d28:ah29 instead of being rewritten to d23:ah24. Likewise with rows d42:ah43.

    Is that a bit clearer?

    Thank you,

    BigDawg15

  8. #8
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,727
    Location
    I'm not sure about the final appearance, but in AddHeaders

    [VBA]
    '------------- Range("E24").Insert
    With Range("E24")
    .Formula = "=(D24+1)"
    .Font.Name = "Arial"
    .Font.Size = 9
    .Font.Bold = True
    .AutoFill Destination:=.Resize(1, Spread), Type:=xlFillDefault
    End With
    [/VBA]

    You are inserting a cell at E24. When I comment it out, it doesn't seem to push it down

    Paul

  9. #9
    Paul,

    Thanks for that, but I tried commenting that out but it did not make a difference. I've fooled around a bit more with the code and it appears it has something to do with the conditional formatting.

    If I comment out the addhighlights portions of the code everything comes out properly aligned, just not with the required shading.

    I'm just not sure what is causing the rows to be out of allignment. The conditional formatting is for shading purposes.

    Thanks again,

    Mike

Posting Permissions

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