Link to home
Start Free TrialLog in
Avatar of Wilder1626
Wilder1626Flag for Canada

asked on

VBA - Paste MSHFlexgrid1 to excel cell

Hello all

I would like to transfer whats in my MSHFlexgrid to my excel cell a specific way but i don't know how to do it.

I would like to start transferring the MSHFlexgrid1 rows on the first empty cell in column A starting at row 5 going down.

I also want to transfer the MSHFlexgrid1 bu rows this way:
MSHFlexgrid1 column 1 in column D in excel
MSHFlexgrid1 column 6 in column F in excel
MSHFlexgrid1 column 9 in column U in excel

How can i do that?

Thanks again for your help
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

I haven't tested this but see if this works.

Dim r As Integer
Dim c As Integer
Dim lngRow As Long

For r = 5 To 65000
    If Cells(r, 1).Value = "" Then
        Exit For
    End If
Next

For lngRow = 1 To MSHFlexGrid1.Rows
    Cells(r, 4).Value = MSHFlexGrid1.TextMatrix(lngRow, 1)
    Cells(r, 6).Value = MSHFlexGrid1.TextMatrix(lngRow, 6)
    Cells(r, 21).Value = MSHFlexGrid1.TextMatrix(lngRow, 9)
    r = r + 1
Next

Open in new window

Avatar of Wilder1626

ASKER

Hi MartinLiss

I have this Run-Time Error 6: Overflow on
For r = 5 To 65000

Open in new window


do you why?
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Can you attach your WB?
Oh this is again so good.

Thanks again for your help.

all work great now.
You're welcome.