Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

I need to generate one prn file for the output

Posted on 2013-12-19
2
Medium Priority
?
406 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:Mohammed Dallag
2 Comments
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 2000 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:Mohammed Dallag
ID: 39735772
Excellent Answer
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
Cancel future meetings from user mailboxes in Office 365 using Remove-CalendarEvents
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

783 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