Solved

I need to generate one prn file for the output

Posted on 2013-12-19
2
398 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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:Mohammed Dallag
ID: 39735772
Excellent Answer
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

This article describes a serious pitfall that can happen when deleting shapes using VBA.
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 …
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
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…

630 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