Solved

I need to generate one prn file for the output

Posted on 2013-12-19
2
354 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

This article will show you how to use shortcut menus in the Access run-time environment.
Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

706 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

17 Experts available now in Live!

Get 1:1 Help Now