Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA Script - need to insert an override


I have created a script which allows me to import from one of my
programs and place the information in designated cells in Excel. The
problem is, I have rounded everything down to two possible scenarios.
What I have seen is that with my original script, the first .cmd runs
throughout the worksheet, if I place an ElseIf on the second variable,
both .cmd lines run together. I don't want this either, what I would
like to see happen is that if when the script finds the next string, if
it is true of variable two, I do not want anything imported fitting the
first variable. Is there a way to toggle between these variables? I
have pasted my code here, any help would be awesome.

Option Explicit
Sub main()
Dim app As Object, cmds As Object, cmd As Object, part As Object
Set app = CreateObject("PCDLRN.Application")
Set part = app.ActivePartProgram
Set cmds = part.Commands
Dim LookForChar
LookForChar = "."
Dim Pos, s As String, i As Integer
Dim Run As Integer, Offset As Integer
s = ""
Run = ActiveSheet.Cells(1, 9)
Offset = ActiveSheet.Cells(2, 9)
Run = Run + 1
ActiveSheet.Cells(1, 9) = Run
i = 10
For Each cmd In cmds
If cmd.IsDimension Then
If cmd.Type = (DIMENSION_TRUE_START_POSITION Or _
DIMENSION_START_LOCATION) Or s < cmd.ID Then
If cmd.ID < "" Then s = cmd.ID
If cmd.Type < DIMENSION_TRUE_START_POSITION And _
cmd.Type < DIMENSION_START_LOCATION Then
If Run < 49 Then
ActiveSheet.Cells(i, 3) =
cmd.DimensionCommand.NOMINAL
ActiveSheet.Cells(i, 10) =
cmd.DimensionCommand.Plus
ActiveSheet.Cells(i, 12) =
cmd.DimensionCommand.Minus
End If
ActiveSheet.Cells(i, (Offset + 15)) =
cmd.DimensionCommand.Measured
End If
ElseIf cmd.Type < DIMENSION_TRUE_END_POSITION Or
DIMENSION_END_LOCATION Then
If Run < 49 Then
ActiveSheet.Cells(i, 1) = s
ActiveSheet.Cells(i, 2).Font.Bold = True
End If
If Run < 49 Then
ActiveSheet.Cells(i, 4) =
cmd.DimensionCommand.NOMINAL
ActiveSheet.Cells(i, 5) =
cmd.DimensionCommand.Plus
'ActiveSheet.Cells(i, 6) =
cmd.DimensionCommand.Minus
End If
ActiveSheet.Cells(i, (Offset + 3)) =
cmd.DimensionCommand.Measured ' + 6
'ActiveSheet.Cells(i, (Offset + 7)) =
cmd.DimensionCommand.Deviation
'ActiveSheet.Cells(i, (Offset + 8)) =
cmd.DimensionCommand.OutTol
End If
If Trim(ActiveSheet.Cells(i, (Offset + 3))) < "" Then
i = i + 1
End If
End If
Next cmd
Offset = Offset + 5
ActiveSheet.Cells(2, 9) = Offset
End Sub


--
Brad J.
------------------------------------------------------------------------
Brad J.'s Profile: http://www.excelforum.com/member.php...o&userid=21713
View this thread: http://www.excelforum.com/showthread...hreadid=549120

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Script to insert Row Jeremy Excel Discussion (Misc queries) 2 April 19th 10 02:39 PM
HOW DO I OVERRIDE THE "COPYRIGHT" SYMBOL TO INSERT (C)? Mattie K Excel Discussion (Misc queries) 1 April 9th 09 03:15 PM
Need VBA script to auto-insert value upon row insert Phil Excel Worksheet Functions 4 May 6th 08 02:41 PM
Script to insert the next Friday Mark Langendoerfer Excel Programming 1 April 12th 05 09:57 PM
insert excel vb script bt707[_6_] Excel Programming 1 October 18th 03 03:43 PM


All times are GMT +1. The time now is 01:02 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"