Re: Mappoint 2006 Vba Support
Now i see why no one is replying. My question not only does not sound like a question but does not have a question mark. I am going to edit my first entry above to make it more clear.
Re: Mappoint 2006 Vba Support
Now i see why no one is replying. My question not only does not sound like a question but does not have a question mark. I am going to edit my first entry above to make it more clear.
Re: If Statement Causing Loop To Fail
There are no rules on indenting your code. It just makes it easy on you to find your mistakes.
Re: Format Date/time - Hide Time If Time Is 12:00am
One thing to consider. If it is being entered by a formula, the best way out is to filter the formula's results by putting in an if statement like the below.
=if([your entire cell contents now without the preceding equal sign]="","",[your entire cell contents now without the preceding equal sign])
This causes the formula output type to be string data instead of numeric. The formula cannot assume it's result should be zero.
HTH's
Re: Mappoint 2006 Vba Support
The above code would be of course entered into a module in Excel. The cool idea is being able to get driving distance by simply entering the addresses in to a spreadsheet. Zip code to zip code distances can be off by 20 miles or more in any situation, and it some cases 100's of miles. This mainly happens when mapping 2 between 2 zip codes where one is on a peninsula, and one is not.
Re: Format Date/time - Hide Time If Time Is 12:00am
Is the time calculated by a formula or entered by a user?
Re: Mappoint 2006 Vba Support
If anyone out there has Office 2003 and Mappoint 2006, maybe you could try the below code.
Automating MapPoint
In Automation, User Defined Functions, Excel Experts E-Letter by Dick Kusleika
EEE#21: Excel User Defined Functions That Incorporate MapPoint Functionality
By David Hager
---Note: Excel 2003 and MapPoint 2004 were used in the development of this technique and its use with other versions has not been tested.---
The integration that Microsoft provides between Excel and MapPoint for importing and exporting data provides a powerful method for visual data analysis. As it turns out, there is another way to obtain information from MapPoint to Excel that is not as well-known.
User-defined functions (UDF) are used in Excel worksheets is the same way that native Excel functions are used. The VBA code for an Excel UDF is written in a standard module in the Excel VBE and called by entering the function in a formula in a worksheet cell. In order to incorporate MapPoint automation in an Excel UDF, open the Visual Basic Environment (VBE) by using the Alt-F11 keys. Then, under Tools|References check the Microsoft MapPoint 11.0 Object Library (North America).
A simple example of an Excel UDF that incorporates MapPoint functionality is shown below.
Function StraightLineDist(strPoint1, strPoint2)
Dim objApp As New MapPoint.Application
Set objMap = objApp.ActiveMap
Set objLocate1 = objMap.FindResults(strPoint1).Item(1)
Set objLocate2 = objMap.FindResults(strPoint2).Item(1)
StraightLineDist = Application.Round(CStr(objLocate1.DistanceTo(objLocate2)), 5)
End Function
It is quite rare to find an example where the VBA code for an Excel UDF successfully instantiates an application. In this case, an instance of MapPoint is created with the statement
Dim objApp As New MapPoint.Application
that allows the Excel UDF access to a valuable source of location information.
The FindResults method works in the same way that the Place/Data tab in the dialog box opened from Edit|Find of the MapPoint main menu does. The Item(1) property returns the best choice based on the available information. As an example, type the following in an Excel worksheet.
A1: Beaumont, Tx
A2: Houston, Tx
A3: =StraightLineDist(A1, A2)
The result returned in cell A3 is 77.11092, which is the number of miles as the crow flies between Beaumont and Houston Texas as calculated by the DistanceTo method.
In order to improve performance of the StraightLineDist function, the statement
can be used in the code to limit function calls to only those times when the input data is changed. It might be also advantageous to set the MapPoint objects to nothing in order to remove them from memory.
The next example returns the distance for a multiple point route and contains an element that is perhaps unique among UDF?s.
Function MPRouteDist(iMPType As Integer, ParamArray WPoints())
Dim objApp As New MapPoint.Application
Set objMap = objApp.ActiveMap
With objMap.ActiveRoute
For Each wpoint In WPoints
.Waypoints.Add objMap.FindResults(wpoint).Item(1)
Next
.Waypoints.Item(1).SegmentPreferences = iMPType
.Calculate
MPRouteDist = Application.Round(CStr(.Distance), 5)
End With
objMap.Saved = True
End Function
Display More
The iMPType variable is the type of route to be returned:
0 = Travel using the quickest route
1 = Travel using the shortest route
2 = Travel on preferred roads as set in the Preferred Roads dialog box
The ParamArray WPoints() statement allows for an arbitrary number of waypoint function arguments along the route.
By entering the following formula, the distance for the quickest round trip route from Houston is returned (882.89018 miles).
Cell formula:[
where:
A1: Houston, Tx
A2: Dallas, Tx
A3: San Antonio, Tx
A4: Corpus Christi, Tx
This function actually makes changes on the active MapPoint map (not visible) and a prompt appears asking to save those changes unless the statement
is included in the code. This writer does not know of another example where an Excel UDF modifies another application. This unusual behavior serendipitously provides a simple way to generate route maps from Excel. If the following formula is entered without the objMap.Saved = True statement in the code, the route map from Houston to Dallas is generated and can be saved. Thus, generation of route maps from MapPoint is now as easy as entering an address in a worksheet cell.
Cell formula:
In summary, Excel UDFs provide easy access to the rich store of information in MapPoint and these examples just scratch the surface of what is possible. For example, I have made Excel UDFs that draw geometric shapes around MapPoint locations. This and other challenges are left to the reader.
Re: If Statement Causing Loop To Fail
Add two "End if" statements as shown below.
Sheets("Practical & Theory Marks").Range(Cells(Col, Row), Cells(Col, Row + 5)).Copy
End If
End If
I edited your code to make it easier to read. It made it easy to find the error.
Sub TransferDataByRowToAnotherSheet()
'1. Looks to see if a string (name of a student) is present in Column A. If not
'do same to next row. If yes copy name to "StudentName" Range in Record Form Sheet
'2. Returns the number of non empty cells in a range. Loops through 16 ranges per row.
'Copies non empty ranges to Record Form Sheet. Prints Record Form sheet.
'Clears record Form sheet and goes onto next row.
'
Dim Col As Integer, MyCount As Integer, Row As Integer, PupilName As Integer, MyRange As Range
Application.ScreenUpdating = True 'Turn it on for now so I can see what I'm doing :)
Col = 4 'Set starting row
Row = 3 'Set starting column
PupilName = 1
For RowNo = 1 To 32 'Loops down 32 rows
For CountRangesOnEachRow = 1 To 17 'Cycles across 17 ranges on the same row
'Tests to see if there is a name in the A column. If occupied copy cell contents.
'If empty go to next row.
If Trim$(Cells(Col, PupilName)) <> "" Then
Cells(Col, PupilName).Copy Destination:=Worksheets("Record Form Games 3583").Range("StudentName")
Worksheets("Record Form Games 3583").Range("StudentName").Font.Size = 6
Range(Cells(Col, Row), Cells(Col, Row + 5)).Select 'Gets a 6 cell range
MyCount = Application.Count(Selection) 'Counts the number of values in that range
If CountRangesOnEachRow = 17 Then
MsgBox "I'm now on the Study Grades so I am copying it to the record form"
Selection.Copy
Worksheets("Record Form Games 3583").Select
Range("B14").Select
Selection.PasteSpecial Paste:=xlPasteAllExceptBorders
MsgBox "The number of non-blank cell(s) containing numbers is : " & MyCount, vbInformation, "Count Cells"
Row = Row + 9
' If MyCount = 2 Then Do Something
' If MyCount = 6 Then Do Something Else
If CountRangesOnEachRow = 17 Then
Range(Cells(Col, Row), Cells(Col, Row + 5)).Select
Worksheets("Practical & Theory Marks").Select
Range(Cells(Col, Row - 9), Cells(Col, Row - 4)).Copy
Range("B14").Select
Selection.PasteSpecial Paste:=xlPasteAllExceptBorders
MsgBox "Copying Study Marks ...", vbInformation
Worksheets("C").Select
Sheets("Practical & Theory Marks").Range(Cells(Col, Row), Cells(Col, Row + 5)).Copy
End If
End If
End If
Next CountRangesOnEachRow
'Reset start points and drop down a row
Col = Col + 1
PupilName = PupilName + 1
Row = 3
Next RowNo
End Sub
Display More
HTHs...
Does anyone know if Mappoint 2006 has automation support? I know that 2004 does. I am wanting to use the automation from excel's VBA.
Re: Autofilter Compile Error
If that does not help, where ever you got the code will probably have a "With" statement above the line in question detailing what object the .autofiltermode was referencing.
Re: Sum Criteria With Nonblank Cells
You need to change "truetrue" to "truetruetrue". You have to do that each time you add a new condition, unless your new condition needed to be false of course. Then it would be "truefalsetrue".
Re: Creating Range Of Bar Codes
Well I noticed that it might not work well with differing ranges like 9995 to 10560. You would constantly have to update it. Here is a sample of code that you do not need to update constantly.
Re: Creating Range Of Bar Codes
I have found an error with my approach. I am uploading a spreadsheet that shows the corrected info. Keep in mind that I did not do anthing with the barcode or the my company name lines as this does not really involve them.
Re: Creating Range Of Bar Codes
Well does your situation make it so that you have to go left to right on the same row?
Re: Creating Range Of Bar Codes
Ok. How many barcodes to generate at one time? I ask because the solution is different if you want to do a million at a time vs if you want to do a 1000 at a time.
Re: Creating Range Of Bar Codes
How many barcodes are you wanting to generate on avg?
Re: Removal Of Unused Rows (variable Range)
When you are recording a macro, it is the only other button on the record macro toolbar that pops up.
Re: Convert A Column Into Comma Delimited List
To get the text you'll have to copy then Paste Special > Paste:values in excel or you can always just paste it into notepad.
Re: Convert A Column Into Comma Delimited List
Create your own function to loop thru the values and concatenate them. If you know how to insert a module, put this in one.
Function csvRange(myRange As Range)
Dim csvRangeOutput
For Each entry In myRange
csvRangeOutput = csvRangeOutput & entry.Value & ", "
Next
csvRange = csvRangeOutput
End Function
Put this in the cell to grab the first 16 cells of column I:
Re: If And Sum Statement With Nonblank Cells
No problem. Happy to help. I tested it using the 65535 limitation and the calc took about .5 seconds. And that was with my monster spreadsheet open. : D