Results 1 to 7 of 7

Editing BOM automatically

Threaded View

  1. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Editing BOM automatically

    Instead of

    If Cells(x, 1).Value <> Cells(x + 1, 1).Value Then
     Rows(x + 1).select
          
     Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
     Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    you can use:

     
    If Cells(x, 1).Value <> Cells(x + 1, 1).Value Then
      Rows(x + 1).Resize(2).Insert
    But if adding a simple column:

    Private Sub test()
     sn = Cells(1).CurrentRegion.Resize(, 1).Offset(, 9)
     sq = Cells(1).CurrentRegion.Offset(, 1).Resize(, 5)
     sq(1, 1) = 0
       
     For j = 3 To UBound(sn) - 1
      sq(1, 1) = sq(1, 1) + sq(j, 1)
       
      If sq(j, 5) <> sq(j + 1, 5) Then
       sn(j, 1) = sq(1, 1)
       sq(1, 1) = 0
       j = j + 1
      End If
     Next
       Cells(1, 9).Resize(UBound(sn)) = sn
    End Sub
    Last edited by snb; 11-17-2011 at 05:42 PM.



Thread Information

Users Browsing this Thread

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

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