Consulting

Results 1 to 3 of 3

Thread: Modification to copy VBA code

  1. #1

    Modification to copy VBA code

    Hi,

    I have a code which I've been working on modifying with the help of this forum and one certain member so far. It is cross posted here: http://www.mrexcel.com/forum/excel-q...blank-row.html

    I have kind of a piece-meal type question.

    Part the code is:

    
    
    Case T  'copy certain cells to the single inserted row
                                'B, C, D, E, F, G, H, I, J, K, M, S, BH, BI, BJ, BK, BM, BS, BV
                                With Sheets("Services Export Raw")
                                    .Range(.Cells(lRowToCopy, "B"), .Cells(lRowToCopy, "K")).Copy _
                                        Destination:=.Cells(lRowToCopy + 1, "B")
                                    .Range(.Cells(lRowToCopy, "M"), .Cells(lRowToCopy, "M")).Copy _
                                        Destination:=.Cells(lRowToCopy + 1, "M")
                                    .Range(.Cells(lRowToCopy, "S"), .Cells(lRowToCopy, "S")).Copy _
                                        Destination:=.Cells(lRowToCopy + 1, "S")
                                    .Range(.Cells(lRowToCopy, "BH"), .Cells(lRowToCopy, "BK")).Copy _
                                        Destination:=.Cells(lRowToCopy + 1, "BH")
                                    .Range(.Cells(lRowToCopy, "BM"), .Cells(lRowToCopy, "BM")).Copy _
                                        Destination:=.Cells(lRowToCopy + 1, "BM")
                                    .Range(.Cells(lRowToCopy, "BS"), .Cells(lRowToCopy, "BS")).Copy _
                                        Destination:=.Cells(lRowToCopy + 1, "BS")
                                    .Range(.Cells(lRowToCopy, "BV"), .Cells(lRowToCopy, "BV")).Copy _
                                        Destination:=.Cells(lRowToCopy + 1, "BV")
                                End With
    My question is, how would I add a row to this code that instead of copies and pasted to the destination cell it just types in set text

    For example I'm thinking something like this:

    
    
     Case T  'copy certain cells to the single inserted row
                                'B, C, D, E, F, G, H, I, J, K, M, S, BH, BI, BJ, BK, BM, BS, BV
                                With Sheets("Services Export Raw")
                                    .Range(.Cells(lRowToCopy, "B"), .Cells(lRowToCopy, "K")).Copy _
                                        Destination:=.Cells(lRowToCopy + 1, "B")
                                    .Range(.Cells(lRowToCopy, "M"), .Cells(lRowToCopy, "M")).Copy _
                                        Destination:=.Cells(lRowToCopy + 1, "M")
                                    .Range(.Cells(lRowToCopy, "S"), .Cells(lRowToCopy, "S")).Copy _
                                        Destination:=.Cells(lRowToCopy + 1, "S")
                                    .Range(.Cells("T"))_
                                        Desitination:=.Cells(lRowToCopy + 1, "Type Set Text Here")
                                    .Range(.Cells(lRowToCopy, "BH"), .Cells(lRowToCopy, "BK")).Copy _
                                        Destination:=.Cells(lRowToCopy + 1, "BH")
                                    .Range(.Cells(lRowToCopy, "BM"), .Cells(lRowToCopy, "BM")).Copy _
                                        Destination:=.Cells(lRowToCopy + 1, "BM")
                                    .Range(.Cells(lRowToCopy, "BS"), .Cells(lRowToCopy, "BS")).Copy _
                                        Destination:=.Cells(lRowToCopy + 1, "BS")
                                    .Range(.Cells(lRowToCopy, "BV"), .Cells(lRowToCopy, "BV")).Copy _
                                        Destination:=.Cells(lRowToCopy + 1, "BV")
                                End With
    I know this is no where near correct in terms of coding, but it's an example of what I'm trying to do. The rest of the code works fine and copies down the appropriate rows, but I want to insert rows that type certain text instead of copy down from above into this new blank row. Note this post is all cross posted here: http://www.mrexcel.com/forum/excel-questions/916919-modification-copy-visual-basic-applications-code.html#post4408383

    Thanks.

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    .Cells(lRowToCopy + 1, "T") "Type Set Text Here")
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    Thanks SamT! Appreciate it!

Posting Permissions

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