Closed Thread
Results 1 to 8 of 8

Macro code help with ctrl and find/ copy and paste in excel

Hybrid View

leanne2011 Macro code help with ctrl and... 11-24-2011, 06:13 AM
teylyn Re: Excel 2007 Macro code help 11-24-2011, 06:15 AM
teylyn Re: Macro code help with ctrl... 11-24-2011, 06:34 AM
leanne2011 Re: Macro code help with ctrl... 11-24-2011, 06:42 AM
watersev Re: Macro code help with ctrl... 11-24-2011, 08:57 AM
leanne2011 Re: Macro code help with ctrl... 11-24-2011, 09:15 AM
watersev Re: Macro code help with ctrl... 11-24-2011, 09:45 AM
watersev Re: Macro code help with ctrl... 11-24-2011, 10:35 AM
  1. #1
    Forum Contributor
    Join Date
    09-06-2011
    Location
    northern ireland
    MS-Off Ver
    Excel 365
    Posts
    180

    Macro code help with ctrl and find/ copy and paste in excel

    Hi

    I display the code below - I am a novice at this and slowly working on building upon it. I have two spreadsheets, one is variable from month to month (called example.xlsx in the below code) and a fixed spreadsheet which consists of a header row that I need the macro to build each month.

    So the header spreadsheet has headers called salary, salary adj, car allowance etc. The fixed sheet contains all the amounts for the applicable headers but if there is no salary adj in the current month then I need the fixed spreadsheet to have a zero in those fields. What I normally do is record the macro and make any adjustments manually where there is a problem so the code will be longer than the more experienced.

    Please can someone help me with the code - I really appreciate any help at all.

    Code below:




    Sub parttwo()
        
        
        Workbooks.Open Filename:= _
            "N:\PAYROLL\Leanne\example - Macro Work LB only\Excel Spreadsheet Header Row_amended.xlsx"
        
        'Need to sort this out because it can't find salary adj the macro stops working
        
       
        Range("S2").Select
        Cells.Find(What:="Salary Adj", After:=ActiveCell, LookIn:=xlFormulas, _
            LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False).Activate
        Range("T2").Select
        Application.CutCopyMode = False
        With Selection.Font
            .Name = "Microsoft Sans Serif"
            .FontStyle = "Regular"
            .Size = 8
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .TintAndShade = 0
            .ThemeFont = xlThemeFontNone
        End With
        With Selection.Interior
            .Pattern = xlNone
            .TintAndShade = 0
            .PatternTintAndShade = 0
        End With
        Selection.Borders(xlDiagonalDown).LineStyle = xlNone
        Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With Selection.Borders(xlEdgeLeft)
            .LineStyle = xlContinuous
            .ColorIndex = 3
            .TintAndShade = 0
            .Weight = xlThin
        End With
        Selection.Borders(xlEdgeTop).LineStyle = xlNone
        Selection.Borders(xlEdgeBottom).LineStyle = xlNone
        With Selection.Borders(xlEdgeRight)
            .LineStyle = xlContinuous
            .ColorIndex = 3
            .TintAndShade = 0
            .Weight = xlThin
        End With
        Selection.Borders(xlInsideVertical).LineStyle = xlNone
        Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        With Selection
            .HorizontalAlignment = xlRight
            .VerticalAlignment = xlTop
            .WrapText = False
            .Orientation = 0
            .AddIndent = False
            .IndentLevel = 0
            .ShrinkToFit = False
            .ReadingOrder = xlContext
            .MergeCells = False
        End With
        Selection.NumberFormat = "0.00"
        ActiveCell.FormulaR1C1 = "0"
        Range("T2").Select
        Selection.Copy
        Range("T2:T30").Select
        ActiveSheet.Paste
    
    End sub
    Last edited by leanne2011; 11-24-2011 at 08:04 AM. Reason: does not comply with forum rules

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: Excel 2007 Macro code help

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    PLEASE PM WHEN YOU HAVE DONE THIS AND I WILL DELETE THIS POST

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

  3. #3
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: Macro code help with ctrl and find/ copy and paste in excel

    What about the code tags?

  4. #4
    Forum Contributor
    Join Date
    09-06-2011
    Location
    northern ireland
    MS-Off Ver
    Excel 365
    Posts
    180

    Re: Macro code help with ctrl and find/ copy and paste in excel

    How do I tag it ?

  5. #5
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Macro code help with ctrl and find/ copy and paste in excel

    hi, leanne2011, can you post sample workbook showing original data and result you need to obtain?

  6. #6
    Forum Contributor
    Join Date
    09-06-2011
    Location
    northern ireland
    MS-Off Ver
    Excel 365
    Posts
    180

    Re: Macro code help with ctrl and find/ copy and paste in excel

    Quote Originally Posted by watersev View Post
    hi, leanne2011, can you post sample workbook showing original data and result you need to obtain?

    Hello - I re posted this so about 7 posts down "Ctrl find, copy and pasting help please (Macro code needed)
    "

    It has two attachments and a bit more code.

    Thank you for trying to help me
    Leanne

  7. #7
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Macro code help with ctrl and find/ copy and paste in excel

    unfortunately there are no attachments in any of your posts, I suppose you missed to click the Upload button. Please note there is a limit on the attachment size for Excel files - 1 MB. If it is larger you can archive it to decrease its size.
    Last edited by watersev; 11-24-2011 at 10:17 AM.

  8. #8
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Macro code help with ctrl and find/ copy and paste in excel

    looks like duplicate thread with: http://www.excelforum.com/excel-prog...de-needed.html
    As there are no attchments in this thread, I suggest to close it and continue in the above one

Closed 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