Hi everyone,
I'm fairly good with google and fairly beginner with VBA. I've found a VBA command to return a "no data" message in a row I've assigned to allow customers I am sending this file a quick check on the validity of the data. I basically want "no blanks" back from the customer in predefined columns.
However I do not know enough to make my search range dynamic, it's currently set to a dumb "4999" value because 4500 rows is the largest data set I've seen so far. However we have some smaller customers that may only give us 900 rows of data. I want the tool to be smart enough to find the last row of data and set that as the limit. Is there a way to either automatically make this happen, or add one more button to "find" the last row and insert that as the upper limit to the range in the macro?
For reference, this is what I currently have:
Private Sub CommandButton1_Click()
With Application.WorksheetFunction
If .CountA(Range("A14:A4999")) <= 0 Then [A13] = "No Data"
If .CountA(Range("B14:B4999")) <= 0 Then [B13] = "No Data"
If .CountA(Range("C14:C4999")) <= 0 Then [C13] = "No Data"
If .CountA(Range("D14:D4999")) <= 0 Then [D13] = "No Data"
If .CountA(Range("E14:E4999")) <= 0 Then [E13] = "No Data"
If .CountA(Range("F15:F4999")) <= 0 Then [F13] = "No Data"
If .CountA(Range("G15:G4999")) <= 0 Then [G13] = "No Data"
If .CountA(Range("H15:H4999")) <= 0 Then [H13] = "No Data"
If .CountA(Range("I15:I4999")) <= 0 Then [I13] = "No Data"
If .CountA(Range("J15:J4999")) <= 0 Then [J13] = "No Data"
If .CountA(Range("O15:O4999")) <= 0 Then [O13] = "No Data"
If .CountA(Range("P15:P4999")) <= 0 Then [P13] = "No Data"
If .CountA(Range("Q15:Q4999")) <= 0 Then [Q13] = "No Data"
If .CountA(Range("R15:R4999")) <= 0 Then [R13] = "No Data"
If .CountA(Range("S15:S4999")) <= 0 Then [S13] = "No Data"
If .CountA(Range("T15:T4999")) <= 0 Then [T13] = "No Data"
If .CountA(Range("U15:U4999")) <= 0 Then [U13] = "No Data"
If .CountA(Range("V15:V4999")) <= 0 Then [V13] = "No Data"
If .CountA(Range("W15:W4999")) <= 0 Then [W13] = "No Data"
If .CountA(Range("X15:X4999")) <= 0 Then [X13] = "No Data"
If .CountA(Range("Y15:Y4999")) <= 0 Then [Y13] = "No Data"
If .CountA(Range("Z15:Z4999")) <= 0 Then [Z13] = "No Data"
End With
End Sub
I'm fairly good with google and fairly beginner with VBA. I've found a VBA command to return a "no data" message in a row I've assigned to allow customers I am sending this file a quick check on the validity of the data. I basically want "no blanks" back from the customer in predefined columns.
However I do not know enough to make my search range dynamic, it's currently set to a dumb "4999" value because 4500 rows is the largest data set I've seen so far. However we have some smaller customers that may only give us 900 rows of data. I want the tool to be smart enough to find the last row of data and set that as the limit. Is there a way to either automatically make this happen, or add one more button to "find" the last row and insert that as the upper limit to the range in the macro?
For reference, this is what I currently have:
Private Sub CommandButton1_Click()
With Application.WorksheetFunction
If .CountA(Range("A14:A4999")) <= 0 Then [A13] = "No Data"
If .CountA(Range("B14:B4999")) <= 0 Then [B13] = "No Data"
If .CountA(Range("C14:C4999")) <= 0 Then [C13] = "No Data"
If .CountA(Range("D14:D4999")) <= 0 Then [D13] = "No Data"
If .CountA(Range("E14:E4999")) <= 0 Then [E13] = "No Data"
If .CountA(Range("F15:F4999")) <= 0 Then [F13] = "No Data"
If .CountA(Range("G15:G4999")) <= 0 Then [G13] = "No Data"
If .CountA(Range("H15:H4999")) <= 0 Then [H13] = "No Data"
If .CountA(Range("I15:I4999")) <= 0 Then [I13] = "No Data"
If .CountA(Range("J15:J4999")) <= 0 Then [J13] = "No Data"
If .CountA(Range("O15:O4999")) <= 0 Then [O13] = "No Data"
If .CountA(Range("P15:P4999")) <= 0 Then [P13] = "No Data"
If .CountA(Range("Q15:Q4999")) <= 0 Then [Q13] = "No Data"
If .CountA(Range("R15:R4999")) <= 0 Then [R13] = "No Data"
If .CountA(Range("S15:S4999")) <= 0 Then [S13] = "No Data"
If .CountA(Range("T15:T4999")) <= 0 Then [T13] = "No Data"
If .CountA(Range("U15:U4999")) <= 0 Then [U13] = "No Data"
If .CountA(Range("V15:V4999")) <= 0 Then [V13] = "No Data"
If .CountA(Range("W15:W4999")) <= 0 Then [W13] = "No Data"
If .CountA(Range("X15:X4999")) <= 0 Then [X13] = "No Data"
If .CountA(Range("Y15:Y4999")) <= 0 Then [Y13] = "No Data"
If .CountA(Range("Z15:Z4999")) <= 0 Then [Z13] = "No Data"
End With
End Sub