Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Convert Excel Macro

$
0
0

Hi,

If some one can help me to convert this Excel Macro to PowerShell Script, the macros is very successful but it stills/hangs on huge file. (approx. 50 thousand lines)

I import the text file and then this macro does its job.

Public Sub FormatCells()
Dim I As Long, J As Integer
LastRow = ActiveSheet.Cells(Rows.Count, 4).End(xlUp).Row
ActiveSheet.Rows(1).ClearContents

For I = 1 To LastRow
    Cells(I, 8) = Cells(I, 4)
    Cells(I, 8).NumberFormat = "000000"
    For J = 9 To Cells(I, 5) + 7
        Cells(I, J) = Cells(I, J - 1) + 1
        Cells(I, J).NumberFormat = "000000"
    Next J
Next I
LastCol = ActiveSheet.Cells(2, Application.Columns.Count).End(xlToLeft).Column
For J = 9 To LastCol + 1
  Cells(1, J - 1) = "S" & J - 8
Next J
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:= "d:\office\computed.txt ", FileFormat:= _
    xlTextMSDOS, CreateBackup:=False
ActiveWorkbook.Close SaveChanges:=True
Application.DisplayAlerts = True
End Sub

Any helps will be appreciated.

Thanks.


Viewing all articles
Browse latest Browse all 6937

Trending Articles