PDA

View Full Version : [SOLVED] Modification to copy VBA code



nirvehex
01-26-2016, 10:54 AM
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-questions/915479-visual-basic-applications-copy-down-information-into-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.

SamT
01-26-2016, 01:37 PM
.Cells(lRowToCopy + 1, "T") "Type Set Text Here")

nirvehex
01-26-2016, 02:08 PM
Thanks SamT! Appreciate it!