Results 1 to 2 of 2

VB Code to draw rectangle per data size

Threaded View

  1. #1
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    VB Code to draw rectangle per data size

    Hello:

    I have come up with different logic, please see below #2 Post from me.

    Please refer to attached file, Sheet2.
    I am using below code to get the rectangle's as shown.

    1st the code below set the column width based in row 3.
    Then it draws rectangle based on cell data in row 6.

    (New logic : Instead of doing column Width, can we draw the rectangle as shown in row 20 down in attached file...

    Sub SetColumnWidth()
     Columns("B").ColumnWidth = Cells(3, 2).Value
     Columns("C").ColumnWidth = Cells(3, 3).Value
     Columns("D").ColumnWidth = Cells(3, 4).Value
     Columns("E").ColumnWidth = Cells(3, 5).Value
     Columns("F").ColumnWidth = Cells(3, 6).Value
    
    Call rmColumnW
    
    
    End Sub
    
    
    Sub rmColumnW()
      Dim wks           As Worksheet
      Dim cell          As Range
    
      Set wks = ActiveSheet
    
      With wks
        For Each cell In .Range("B6", .Cells(6, Columns.Count).End(xlToLeft))
          .Shapes.AddShape Type:=msoShapeRectangle, _
                           Left:=cell.Left, Top:=cell.Offset(1).Top, _
                           Width:=cell.Value2, Height:=68
                           
                           ColumnWidth = cell.Value2
                           
        'Stop
        Next cell
      End With
    End Sub

    I need to modify the code so that each rectangle starts from begining of Column and end little less then end of that column.
    I have shown in row 20 down what i am trying to accomplish.

    Let me know if you have any questions.
    Thanks.

    Riz
    Attached Files Attached Files
    Last edited by rizmomin; 06-30-2016 at 06:02 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Let dropdown list width expand beyond width of column so people can read answer choices?
    By xdrenched in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 11-15-2023, 02:05 AM
  2. Reconciling units: Column width and image width
    By MarmaladeLover in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-13-2015, 03:03 PM
  3. Replies: 2
    Last Post: 07-30-2014, 11:13 AM
  4. [SOLVED] VB Code to delete column and change column Width
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-28-2014, 06:25 PM
  5. Column Width vs. Text Width
    By jlt199 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-31-2013, 11:45 AM
  6. Replies: 3
    Last Post: 03-22-2013, 12:19 AM
  7. [SOLVED] Set Column Width Based On Total Width Of Other Columns
    By rayneraingoaway in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-28-2006, 06:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1