excel - I want to copy column D:I,K,O,AG,AH,AA but it currently copies D:AH -
sub autofillData () dim dimmed as the wkbkSource workbook strpath string dim myRange as the range dims as I rounded the integer As the range dim wkbkTarget workbook application. Screen upting = set the wrong straddle = "\\ temp \" wkbkA = set this workbook wkbkB = workbooks. Open (Streets and Range ("E8"). Value) set myRange = wkbkA.Sheets ("stand-up request"). Range ("B13: B25") off = 0 for every C in my range i = C. Value wkbkB.Worksheets ("Chief Data"). Range ("D" & amp;;: "AH" & Amp; i) .Copy wkbkA.Sheets ("stand-up request") Range ("C13") Offset (Offs, 0). Paste Special Paste: = xlPasteValues, Operation: = xlNone, _ SkipBlanks: = True, Transpose: = False application.CutCopyMode = False offs = offs + 1 Error restart Next Next wkbkB.Close savechanges: = False application.ScreenUpdating = True E Nd Sub
If you do not pay attention to the column order, One should change the line:
wkbkB.Worksheets ("main data"). Category ("D" & amp; I & amp; nbsp; & quot;: & quot; & quot; & amp; & quot; & quot; & quot; & quot; & quot; & quot; & amp; & amp; & amp; Amp; & amp; nbsp; & amp; nbsp; & amp; quot; AH & amp; I & amp;;, AA & amp;;). Copy
Note that this is pasted before AA AG If you keep the column order in mind, then you should split your threshold and copy them separately:
wkbkB.Worksheets ("main data"). Category ("D" & amp; I: I & amp; A & amp; A & amp;;, & quot ;, & quot; & & amp; & amp; Copy wkbkA.Sheets ("Range (" C13 ") Offset (Offs, 0) .Paste Special Paste: = XLPistEvices, Operation: = xlNone, _ SkipBlanks: = True, Transpose: = False wkbkB.Worksheets (" Main Data Range ("AA" & amp; i) .copy wkbkA.Sheets ("stand-up request"). Range ("C13") offset (off, 10) .Paste Special Paste: = xlPasteValues, Operation: XlNone, _ SkipBlanks: = True, Transpose: = False Note that this is a static code, if you want to If you change the column to copy, you should also set the column value of the offset of the second paste accordingly. If you want a dynamic code, then you should create another range object that you copy and you get the dimension of that limit Besides,
wkbkA.Sheets ("stand-up request") can also save copy / paste completely by using code. Range ("C13") Offset (Offs, 0). Resize (1, 6) ). Value = wkbkB.Worksheets ("Main Data"). Category ("D" and "I:" I "& amp; i). Value
But it is necessary for each sub-limit to be done, so it becomes more complex .
Also keep in mind that your code works properly on the ActiveSheet without any error , so that you check your code again :)
Comments
Post a Comment