How to create a macro to Freeze Panes at D10

Ask a how-to question
OS version: Mint 22.3
App version: 9.2.1.43
Downloaded from: Mint Software Manager
Additional information:

I am trying to return the cursor to Cell A10 (when panes are frozen at D10) either by a macro or by entering A10 into the Name box (beside fx on the tool bar). In both scenarios the cursor returns A10 but the focus remains on the cell it was originally on. Unfreezing the panes and then returning the cursor to Cell A10 either by a macro or by entering A10 into the Name box DOES move the cursor to A10 as well as the view focus to A10.
As a workaround I am trying to create a macro that will:
~Unfreeze panes
~Move cell focus to A10 (i.e. move the cursor and view focus to A10)
~Refreeze the panes at cell D10

I have been able to create the unfreeze macro:
(function(UnfreezePane)

{

let worksheet = Api.GetActiveSheet();

let freezePanes = worksheet.GetFreezePanes();

freezePanes.Unfreeze();

})();

I have also been able to create the move cursor to A10 Macro:
(function () {
var sheet = Api.GetActiveSheet();
sheet.GetRange(“A10”).Select();
})();

But I cannot create a macro that works to refreeze the panes at cell D10

Can anyone help with this macro or suggest how to achieve the same result in another way.

Thank you :slight_smile:

I kept on trying and eventually found a solution that works.

Note that a short pause is required between Function 2 & 3 to get this to work:

(function() {

// Unfreeze Worksheet
let func1 = function() {
let worksheet = Api.GetActiveSheet();
let freezePanes = worksheet.GetFreezePanes();
freezePanes.Unfreeze();
};

// Return Cursor to A10
let func2 = function() {
var sheet = Api.GetActiveSheet();
sheet.GetRange(“A10”).Select();
};

// Refreeze Panes
let func3 = function() {
let worksheet = Api.GetActiveSheet();
let freezePanes = worksheet.GetFreezePanes();
let range = Api.GetRange(‘A7:G7’);
freezePanes.FreezeAt(range);

// Pause to refreeze panes
};

func1(); // Call first function
func2(); // Call second function
setTimeout(func3, 100); // Call third function after 1/2 second

})();

Hello, @rde :blush:
Glad to hear you managed to find a working solution — thanks a lot for sharing your workaround with the setTimeout delay! It will definitely help other users who run into the same behavior with frozen panes.