Equivalent Code in Javascript

aruny2kprasad

New Member
Joined
Mar 15, 2005
Messages
2
Hi,
I am trying to write a javascript code to access each cell in a range in Excel and modify the attribute.

VB code is

For Each Acell In Range("A1:C20")
If Acell.Text = "SMITH (4)" Then
Acell.Select
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With

I would like to remove Hyperlink, autoformat and keep the color while removing the hyperlink from the active cell. Please provide the javascript code.

The current code i have is,

function bringToExcel()
{
this.document.execCommand("SelectAll", true);
this.document.execCommand("Copy", true);
this.document.execCommand("UnSelect", false);
this.document.execCommand("Unlink", false);

var xlApp, xlBook, xlSheet;
var Col1, col2, col3;
var oRng1;
xlApp = new ActiveXObject("Excel.Application");
xlApp.Visible = true;
xlBook = xlApp.Workbooks.Add();
xlSheet = xlApp.ActiveSheet;
xlSheet.Paste();
// for (oRng1 in xlSheet.Range("A1", "C20"))
// {
// oRng1.ActiveCell.Interior.ColorIndex = "37";
// oRng1.ActiveCell.Hyperlinks.Delete();
// }
oRng1 = xlSheet.Range("A1", "C20")
oRng1.Font.Bold = true;
oRng1.EntireColumn.AutoFit();
oRng1.Hyperlinks.Delete();
oRng1.Interior.ColorIndex = "37";
xlApp.Visible = true;
xlApp.UserControl = true;

}

Please somebody let me know how to loop at each cell in a range with javascript?

Thank you
Arun
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Forum statistics

Threads
1,224,836
Messages
6,181,251
Members
453,027
Latest member
Lost_in_spreadsheets

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top