Solved

I need to generate one prn file for the output

Posted on 2013-12-19
2
366 Views
Last Modified: 2013-12-23
Dear All,

I am generating in my attached excel sheet more than the Excel limit data and I need to split that to different sheets, if it exceed the limit. Could you help me in that?

Or I need to generate one prn file for the output

The Excel Macro is attached.

Regards,

Dallag
GRIDPETREL.xlsm
0
Comment
Question by:dallagmm
2 Comments
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 500 total points
ID: 39729798
Try this macro. Make sure you change the filename/pathname to your own.

Public Sub FillGrid()
    Dim lngv As Single
    Dim intx As Integer
    Dim inty As Integer
    Dim intval, intvaly, intvalx As Long
    intval = 0
    Dim minGridx, minGridy, maxGridx, maxGridy, GridSizeX, GridSizeY, XStep, Ystep, sngval, PetrelNull As Single
    Dim strval As String
    Open "C:\Users\SSaqib\Documents\Gridpetrel.prn" For Output As #1
    'Worksheets("PETRELGRID").Range("A1:IV40001").Clear
    minGridx = Sheets("PARAM").Cells(2, 1)
    minGridy = Sheets("PARAM").Cells(2, 2)
    maxGridx = Sheets("PARAM").Cells(2, 3)
    maxGridy = Sheets("PARAM").Cells(2, 4)
    GridSizeX = Sheets("PARAM").Cells(2, 5)
    GridSizeY = Sheets("PARAM").Cells(2, 6)
    XStep = (maxGridx - minGridx) / GridSizeX
    Ystep = (maxGridy - minGridy) / GridSizeY
    PetrelNull = Sheets("PARAM").Cells(2, 7)
    intvalx = 0
    For inty = 1 To Sheets("PARAM").Cells(2, 6) 'F2
        intvalx = intvalx + 1
        intvaly = 0
        For intx = 1 To Sheets("PARAM").Cells(2, 5) 'E2
            intval = intval + 1
            'Sheets("PETRELGRID").Cells(intval, 1) = minGridx + (intx - 1) * XStep
            'Sheets("PETRELGRID").Cells(intval, 2) = minGridy + (inty - 1) * Ystep
            sngval = Sheets("OFMGRID").Cells(GridSizeX - intvalx + 1, 1 + intvaly)
            If sngval = 0 Then
                strval = Trim$(Sheets("OFMGRID").Cells(GridSizeX - intvalx + 1, 1 + intvaly))
                If Len(strval) = 0 Then sngval = PetrelNull
            End If
            'Sheets("PETRELGRID").Cells(intval, 3) = sngval
            Print #1, minGridx + (intx - 1) * XStep, minGridy + (inty - 1) * Ystep, sngval
            intvaly = intvaly + 1
        Next intx
    Next inty
End Sub
0
 

Author Closing Comment

by:dallagmm
ID: 39735772
Excellent Answer
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now