Jump to content

Excel VBA to AutoCAD VBA Problem


kunekainen

Recommended Posts

Edit: Solved. Thanks.

 

Hi there. At first sorry for my English.

 

I'm an AutoCAD VBA newbie and trying to convert a Excel VBA code to AutoCAD VBA environment. It's a macro which calculates rebar quantity and I converted some of it but i'm having trouble with this:

 

This is a part of my original code:

 

        
           'one row spanning several columns
           Dim Destination As Range
           
           If mainGUI.ComboBox1.Value = "Ayrı" Then
           
               Set Destination = Range("D" & i)
           
           End If
               
           If mainGUI.ComboBox1.Value = "Poz Yok" Then
           
               Set Destination = Range("D" & i)
               Range("C" & i).Value = 0
               
           End If
           
           If mainGUI.ComboBox1.Value = "Birleşik" Then
           
               Set Destination = Range("C" & i)
                               
           End If
                       
           Set Destination = Destination.Resize(1, UBound(Arr))
           
           Destination.Value = Arr
           
           Range("C" & i).Value = Range("C" & i).Value / 1
           Range("E" & i).Value = Range("E" & i).Value / 1
           Range("G" & i).Value = 1
                       
           If InStr(Range("D" & i).Value, "X") <> 0 Then
   
               posx = InStr(Range("D" & i).Value, "X")
               lenx = Len(Range("D" & i).Value)
               
               Range("D" & i).Value = Left(Range("D" & i).Value, posx - 1) * Right(Range("D" & i).Value, lenx - posx)
       
           Else
                    
               Range("D" & i).Value = Range("D" & i).Value / 1
                       
           End If

           
           If InStr(Range("F" & i).Value, "~") <> 0 Then
           

   
               posx = InStr(Range("F" & i).Value, "~")
               lenx = Len(Range("F" & i).Value)
               
               x = Left(Range("F" & i).Value, posx - 1)
               y = Right(Range("F" & i).Value, lenx - posx)
               
               Range("F" & i).Value = (x + y) / 200
       
           Else
           
           Range("F" & i).Value = Range("F" & i).Value / 100
           
           End If

The problem is I don't know how to convert

 

Set Destination = Range("D" & i)

I have an AcadTable object but as you know it hasn't got the Range object. How can I solve this.

 

Thanks in advance for your valueable time.

Edited by kunekainen
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...