Need dedicated support? Click here
Need dedicated support?
Click here

Trata sobre la funcion para una macro de guardar

(function() {
var oWorksheetGuiaDespacho = Api.GetWorkbook().GetWorksheet(3); // “GUIA DESPACHO”
var oWorksheetHistorialGuias = Api.GetWorkbook().GetWorksheet(4); // “HISTORIAL GUIAS”

var copiedData = oWorksheetGuiaDespacho.GetRange('A1:F30').GetValues();



no funciona please

Hello @Javierlucho64

Please note that the official languages of this forum are English and Chinese, consider rewriting your post.

As for the problem, if your goal is to copy certain range from one sheet to another with macros, you can use this example:

var oSheet1 = Api.GetSheet('Sheet1');
var oSheet2 = Api.GetSheet('Sheet2');
var oRange = oSheet1.GetRange("D8:G15");
var rValue = oRange.GetValue();

Where you have to use method GetSheet with the names of needed sheets.

The code is fine but I also want it to copy the styles of the cells… let’s see, I’ll explain, friend, it’s for a button called SAVE which, when pressed, copies the content of one sheet and passes it to the other, but I also want that that hit stays there not to replace it since it is to have a record of guides. Could you help me, thanks:,).

In general, if I understand you correctly, you can copy your original sheet as the additional sheet, in that additional sheet apply all formatting you need (or in the original sheet before copying) and then use macro above to replace the values only. That way, no formatting loss will occur.

If I’m missing something, let me know.

Es que quiero que la macro no solamente copie los valores sino que tambien todo el estilo de la celda como sus colores y tipografía amigo.

For this purpose you can use Copy method. For instance, like that:

var oSheet1 = Api.GetSheet('Sheet1');
var oSheet2 = Api.GetSheet('Sheet2');
var oRange = oSheet1.GetRange("A1:C6");


It copies specified range to another range preserving formatting.