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, 2023 in Others by Kithuzzz
• 38,010 points
213 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, 2023 by narikkadan
• 63,420 points

Related Questions In Others

0 votes
1 answer

Check multiple cells in excel, move to next cell if null and if value found stop and return that value

Use this formula: =INDEX(FILTER(A2:D2,A2:D2<>""),1,1) INDEX returns the first value ...READ MORE

answered Mar 24, 2023 in Others by Kithuzzz
• 38,010 points
256 views
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
• 63,420 points
859 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
• 63,420 points
435 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
• 63,420 points
461 views
0 votes
1 answer

VBA Loop To Import Changing File Names

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

answered Jan 12, 2023 in Others by narikkadan
• 63,420 points
505 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, 2023 in Others by narikkadan
• 63,420 points
251 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, 2023 in Others by narikkadan
• 63,420 points
393 views
0 votes
1 answer

How can increase the speed of if statement in VBA Code?

Use a Dictionary Object. Option Explicit Sub PreencherO() ...READ MORE

answered Feb 7, 2023 in Others by narikkadan
• 63,420 points
305 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
• 63,420 points
374 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
• 63,420 points
1,110 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