开发者

VBA Explanation: For Loops, Null-Checking and +Cells

开发者 https://www.devze.com 2023-02-10 13:15 出处:网络
I have problem with this code: For i = 18 To 19 + Cells(1, 9) If Cells(i,3) = Null Then MsgBox \"Nie sú zadané vš开发者_高级运维etky vstupné údaje pre príjem za prenájom, doplňte chýbajúce

I have problem with this code:

     For i = 18 To 19 + Cells(1, 9)
      If Cells(i,3) = Null Then
        MsgBox "Nie sú zadané vš开发者_高级运维etky vstupné údaje pre príjem za prenájom, doplňte chýbajúce políčka!", vbCritical
        ActiveSheet.Protect Password:="excel", DrawingObjects:=True, Contents:=True, Scenarios:=True
        Exit Sub
      End If
     next i

I know that this code check cells on null values. However, what does the first line do? It is a loop which has steps from 18 to 19, but what does it mean when it says +Cells(1,9)?


...what does it mean +Cells(1,9)

The loop will be from 18 to 19 + Cells(1, 9). E.g., it's adding the value from Cells(1, 9) to 19 to determine when the loop will stop. So if Cells(1, 9) contains 3, for instance, the loop will be from 18 to 22.


Off-topic: Are you sure the If Cells(i,3) = Null bit works? It's been a long time since I did any VBA, but I thought you had to check for Null via IsNull, e.g.: If IsNull(Cells(i,3)). FWIW.

0

精彩评论

暂无评论...
验证码 换一张
取 消