How to add if this cell 0 skip and go next

0 votes

I have something that will automatically produce items for me, but I want it to skip and not produce if this cell is equal to zero after performing select accounting.

Sub AutoMakeInv()

    Dim lPrefix As Long
    Dim lCount As Long
    Dim Account_Number As String

    For lPrefix = 1 To 14
        For lCount = 1 To 2000
            Account_Number = "F" & Format(lPrefix, "00") & " " & Format(lCount, "0000")
            Debug.Print Account_Number
            Cells(8, 5).Value = Account_Number
            Call SelectAcct
            Call ProduceInv
            ' Do something ...
        
        Next lCount
    Next lPrefix

End Sub
Jan 20 in Others by Kithuzzz
• 27,740 points
31 views

1 answer to this question.

0 votes

Try this:

Option Explicit
Sub AutoMakeInv()

    Dim lPrefix As Long
    Dim lCount As Long
    Dim Account_Number As String

    For lPrefix = 1 To 14
        For lCount = 1 To 2000
            Account_Number = "F" & Format(lPrefix, "00") & " " & Format(lCount, "0000")
            Debug.Print Account_Number
            Cells(8, 5).Value = Account_Number
            If Not Range("INSERT YOUR CELL ADDRESS").Value = 0 Then
                Call SelectAcct
                Call ProduceInv
            End If
        Next lCount
    Next lPrefix

End Sub
answered Jan 20 by narikkadan
• 51,240 points

Related Questions In Others

0 votes
1 answer

How do I align a UserForm next to the active cell?

Answer to Q1 - Yes, it's correct. In ...READ MORE

answered Oct 27, 2022 in Others by narikkadan
• 51,240 points
165 views
0 votes
1 answer

How to add check symbol in excel cell SXSSFSheet java

Try this: import java.io.FileOutputStream; import org.apache.poi.xssf.streaming.*; class CreateSXSSFUnicode { public ...READ MORE

answered Nov 13, 2022 in Others by narikkadan
• 51,240 points
67 views
0 votes
1 answer

How to add Header and Footer in excel with vb.net?

This code will work: Imports Microsoft.Office.Interop Private Sub Button1_Click(sender ...READ MORE

answered Dec 10, 2022 in Others by narikkadan
• 51,240 points
87 views
0 votes
1 answer

How to merge two Tables and Add the amount at the same time?

Use SUMPRODUCT like this: =SUMPRODUCT(($A$2:$A$5=A10)*$B$2:$B$5)+ ...READ MORE

answered Jan 7 in Others by narikkadan
• 51,240 points
43 views
0 votes
1 answer

VBA Loop To Import Changing File Names

You can use a FOR loop and ...READ MORE

answered Jan 12 in Others by narikkadan
• 51,240 points
44 views
0 votes
1 answer

Trying to run different macros based on value of cell in a range

This demonstrates one approach to loop through ...READ MORE

answered Jan 19 in Others by narikkadan
• 51,240 points
32 views
0 votes
1 answer

Automating production of graphs using VBA

You have to change: chrtname = Cells(i, 2).Value To: chrtname ...READ MORE

answered Jan 23 in Others by narikkadan
• 51,240 points
35 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
522 views
0 votes
1 answer

Yoast Seo breadcrumbs: How to add custom text to category and tag name

use this code  add_filter('wpseo_breadcrumb_single_link', 'filter_breadcrumbs_for_h1', 10, 2); function filter_breadcrumbs_for_h1($link_output, ...READ MORE

answered Feb 12, 2022 in Others by narikkadan
• 51,240 points
130 views
0 votes
1 answer

Yoast Seo breadcrumbs: How to add custom text to category and tag name

add_filter('wpseo_breadcrumb_single_link', 'filter_breadcrumbs_for_h1', 10, 2); function filter_breadcrumbs_for_h1($link_output, $link) {     if ...READ MORE

answered Feb 25, 2022 in Others by narikkadan
• 51,240 points
516 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP