Greetings,
I am trying to create this loop based on B.O.M. information. Columns A through D show an example of the B.O.M. info that I need to use to create a script to run some commands in AutoCAD. Unfortunately my loop is a failure.
In the attached PNG, the loop part should output starting at E11. It does start there but doesn't work correctly as you can see.
I have put in what the loop is supposed to look like starting at H11 but I haven't been able to make it do that.
All the extra MSGBOX popups are for trying to see what is going on and will be removed later.
I would appreciate any help on the subject,
EDIT-EDIT
Maybe I can't do attachments yet. Here is an attempt to describe what should be there.
The first 4 columns in the excel file contain the imported B.O.M. that looks like this
EDIT-EDIT
Well the attachment did appear but I will leave the extra stuff in here anyway. What is shown starting at E11 should look like what I typed in at H11.
1 partno1 description1 qty1
2 partno2 description2 qty2
3 partno3 description3 qty3
4 partno4 description4 qty4
5 partno5 description5 qty5
6 partno6 description6 qty6
7 partno7 description7 qty7
8 partno8 description8 qty8
9 partno9 description9 qty9
10 partno10 description10 qty10
When I run the macro it looks like this starting at e11:
-insert
-insert
-insert
-insert
-insert
-insert
-insert
-insert
-insert
-insert
BDESCRIP=K:/Cadr13/customer/blocks/drawing_setup/BDESCRIP
S
1
0,-12.25
0
It should look like this:
0
-insert
BDESCRIP=K:/Cadr13/customer/blocks/drawing_setup/BDESCRIP
S
1
0,-10.25
0
-insert
BDESCRIP=K:/Cadr13/customer/blocks/drawing_setup/BDESCRIP
S
1
0,-10.5
0
-insert
BDESCRIP=K:/Cadr13/customer/blocks/drawing_setup/BDESCRIP
S
1
0,-10.75
0
-insert
BDESCRIP=K:/Cadr13/customer/blocks/drawing_setup/BDESCRIP
S
1
0,-11.00
0
-insert
BDESCRIP=K:/Cadr13/customer/blocks/drawing_setup/BDESCRIP
S
1
0,-11.25
0
etc. etc. (repeats 10 times in this example)
Thanks,
Doug
Sub DSI_BDESCRIP()
Dim b4blankcol As Integer
Dim itemx As String
Dim part_nox As String
Dim descriptionx As String
Dim qtyx As String
Dim index1 As Integer
Dim IPY As Double
Dim CP1Y As Single
Dim CP2Y As Single
Dim rino As Integer
Dim rpno As Integer
Dim rdno As Integer
Dim rqno As Integer
'Added the section below so that drawing numbers like 99114E001 wouldn't display
' as 9.91E+05, also added the part that Autofits the text
Columns("A:G").Select
Selection.NumberFormat = "@"
IPY = -10
CP2Y = -10.25
b4blankcol = Range("A1").End(xlDown).Row
MsgBox "Used Cells up to first blank = " & b4blankcol
Cells(1, 5).Value = "tilemode"
Cells(2, 5).Value = "1"
Cells(3, 5).Value = "limits"
Cells(4, 5).Value = "off"
Cells(5, 5).Value = "-insert"
Cells(6, 5).Value = "BTTLE=K:/Cadr13/customer/blocks/drawing_setup/BTTLE"
Cells(7, 5).Value = "s"
Cells(8, 5).Value = "1"
Cells(9, 5).Value = "0,-9.5"
Cells(10, 5).Value = "0"
Cells(11, 5).Value = "Zoom"
Cells(12, 5).Value = "extents"
index1 = b4blankcol
Do While b4blankcol >= 1
Cells((index1 + 1), 5) = "-insert"
Cells((index1 + 2), 5) = "BDESCRIP=K:/Cadr13/customer/blocks/drawing_setup/BDESCRIP"
Cells((index1 + 3), 5) = "S"
Cells((index1 + 4), 5) = "1"
Cells((index1 + 5), 5) = "0," & IPY
Cells((index1 + 6), 5) = "0"
index1 = (index1 + 1)
b4blankcol = (b4blankcol - 1)
IPY = (IPY - 0.25)
Loop
MsgBox "index-1 at the end? " & index1
MsgBox "b4 blankcol at the end " & b4blankcol
End Sub
Bookmarks