I was asked to post the question on this forum.
I have an existing vba code which copies a template from one sheet to another worksheet, and shifting existing data to right.
I just added an excerpt of the code here with super long worksheet names in an effort to avoid back and forth questions :) I am trying to achieve the same using Excel Web Access with javascript.
Dim sourceColumn As Range, targetColumn As Range
Set sourceColumn = Worksheets("WorkSheetContainingTemplateToBeCopied").Columns("C")
Worksheets("TargetSheetWhereTemplateNeedsToBeCopiedAtColumnCWithExisitingDataMovedToRight").Columns("C").Insert Shift:=xlToRight
Set targetColumn = Worksheets("TargetSheetWhereTemplateNeedsToBeCopiedAtColumnCWithExisitingDataMovedToRight").Columns("C")
sourceColumn.Copy Destination:=targetColumn
I started typing the code, but looking at the api, I felt lost. How do I say insert the data into the targetsheet at column C and move any data existing there.
function CopyRange(SourceSheetName, TargetSheetName) { var ewa = Ewa.EwaControl.getInstances().getItem(0); var sheets = ewa.getActiveWorkbook().getSheets(); sourceSheet = sheets.getItemByName(SourceSheetName); targetSheet = sheets.getItemByName(TargetSheetName); sourceSheet.getRangeA1Async("C:C", getSourceTableRange, null); }
function getSourceTableRange(asyncResult) { if (asyncResult.getCode() == 0) { sourceRangeValues = asyncResult.getReturnValue(); } }