Solved

VBA - Paste MSHFlexgrid1 to excel cell

Posted on 2013-01-09
6
255 Views
Last Modified: 2013-01-09
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
0
Comment
Question by:Wilder1626
  • 4
  • 2
6 Comments
 
LVL 46

Expert Comment

by:Martin Liss
ID: 38759266
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

0
 
LVL 11

Author Comment

by:Wilder1626
ID: 38759302
Hi MartinLiss

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

Open in new window


do you why?
0
 
LVL 46

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 38759322
I'm sorry

Dim r As Long

But you shouldn't be running into that error because r should find a value in col A before r gets to big (an integer can only go to 32,767). Also you don't need 'c'.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 46

Expert Comment

by:Martin Liss
ID: 38759326
Can you attach your WB?
0
 
LVL 11

Author Closing Comment

by:Wilder1626
ID: 38759377
Oh this is again so good.

Thanks again for your help.

all work great now.
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 38759564
You're welcome.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
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‚Ķ

839 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