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

x
?
Solved

VBA - Paste MSHFlexgrid1 to excel cell

Posted on 2013-01-09
6
Medium Priority
?
263 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 49

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 49

Accepted Solution

by:
Martin Liss earned 2000 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 49

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 49

Expert Comment

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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

886 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