VB Code Help

Get_Involved

Active Member
Joined
Jan 26, 2007
Messages
383
This Code works perfect when all the columns C28:I28 in the "Bid Calculator" have data in them.
When I keep, the columns filled together it also works with the other columns blank.
Sometimes I need to leave one of the columns blank, and fill the rest it doesn’t work.
Can someone fix the code in Row (13) to skip the blank, and work with the other columns also?

Code:
 Private Sub Workbook_Open()
Dim Ans As String, cell As Range
Ans = MsgBox("Update Invoice Number (???)", vbYesNo + vbInformation)
If Ans = vbYes Then
    For Each cell In Sheets("Legend").Range("E4:E18")
        If cell.Value = Sheets("Bid Calculator").Range("C2").Value Then
            Sheets("Legend").Cells(cell.Row, 5).Offset(, 12).Value = WorksheetFunction.Max(Sheets("Bid Calculator").Range("E5:E5")) + 1
            Sheets("Legend").Cells(cell.Row, 5).Offset(, 13).Value = WorksheetFunction.Max(Sheets("Bid Calculator").Range("C28:I28")) + 1
            Sheets("Legend").Range("S4:S18").Value = WorksheetFunction.Max(Sheets("Bid Calculator").Range("E7:E7")) + 1

        Exit Sub
        End If
    Next cell
   ' Sheets("Legend").Cells(cell.Row, 5).Offset(, 12).Value = Sheets("Legend").Cells(cell.Row, 5).Offset(, 12).Value + 1
   ' Sheets("Legend").Cells(cell.Row, 5).Offset(, 13).Value = Sheets("Legend").Cells(cell.Row, 5).Offset(, 13).Value + 1
   ' Sheets("Legend").Cells(cell.Row, 5).Offset(, 14).Value = Sheets("Legend").Cells(cell.Row, 5).Offset(, 14).Value + 1

      End If
   End Sub

https://www.dropbox.com/s/exm1hp6jbdhsnki/Revew With Dropbox.xlsm?dl=0
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Let me know if I need to explain better what I need in row 13.

This Code works perfect when all the columns C28:I28 in the "Bid Calculator" have data in them.
When I keep, the columns filled together it also works with the other columns blank.
Sometimes I need to leave one of the columns blank, and fill the rest it doesn’t work.
Can someone rewrite the code in Row (13) to skip the blank, and work with the other columns also?

Code:
 Private Sub Workbook_Open()
Dim Ans As String, cell As Range
Ans = MsgBox("Update Invoice Number (???)", vbYesNo + vbInformation)
If Ans = vbYes Then
    For Each cell In Sheets("Legend").Range("E4:E18")
        If cell.Value = Sheets("Bid Calculator").Range("C2").Value Then
            Sheets("Legend").Cells(cell.Row, 5).Offset(, 12).Value = WorksheetFunction.Max(Sheets("Bid Calculator").Range("E5:E5")) + 1
            Sheets("Legend").Cells(cell.Row, 5).Offset(, 13).Value = WorksheetFunction.Max(Sheets("Bid Calculator").Range("C28:I28")) + 1
            Sheets("Legend").Range("S4:S18").Value = WorksheetFunction.Max(Sheets("Bid Calculator").Range("E7:E7")) + 1

        Exit Sub
        End If
    Next cell
   ' Sheets("Legend").Cells(cell.Row, 5).Offset(, 12).Value = Sheets("Legend").Cells(cell.Row, 5).Offset(, 12).Value + 1
   ' Sheets("Legend").Cells(cell.Row, 5).Offset(, 13).Value = Sheets("Legend").Cells(cell.Row, 5).Offset(, 13).Value + 1
   ' Sheets("Legend").Cells(cell.Row, 5).Offset(, 14).Value = Sheets("Legend").Cells(cell.Row, 5).Offset(, 14).Value + 1

      End If
   End Sub

https://www.dropbox.com/s/exm1hp6jbdhsnki/Revew With Dropbox.xlsm?dl=0
 
Upvote 0

Forum statistics

Threads
1,213,530
Messages
6,114,163
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top