VBA Code to Count Number of Filled Spaces in Entry Form

UncleBajubjubs

Board Regular
Joined
Jul 11, 2017
Messages
111
Office Version
  1. 2010
Hello, my workbook is set up to copy a sheet from another workbook into it. Someone will fill out a worksheet with their data, and someone else will use my program to work with the data. The form they fill in has a few spaces for "additional notes", ie, essentially any information that doesn't have a spot to go in.

The program pulls in the data just fine, and I'd like it to have a message box pop up when they use the macro that copies the sheet. The message box will tell them "X number of additional notes were added, please check.", with X being the number of cells designated for "additional notes" that were typed into. Any ideas as to how to do this neatly? Thanks!
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
We'd need to know how you're copying the data to the worksheet, or you could always do a test to see if the "additional notes" cells are blank after the copy, and if not consider that note were added and usg your msgbox to inform user.
 
Upvote 0
Basically in my workbook, it opens the dialogue to select a file to link, then it copies the completed form you select to a blank version of that form on a sheet in my workbook. At present, what I have is

<code>
Public Sub Comments()
Dim notes As Integer
notes = 0


Worksheets("the copied worksheet").Activate


If Not IsEmpty("cell1") Then
notes = notes + 1
End If


If Not IsEmpty("cell2") Then
notes = notes + 1
End If


If Not IsEmpty("cell3") Then
notes = notes + 1
End If


If Not IsEmpty("cell4") Then
notes = notes + 1
End If


If Not IsEmpty("cell5") Then
notes = notes + 1
End If

MsgBox notes & " flags were found."


End Sub

</code>

But it's say making notes equal to five even with nothing in those 5 cells. I'm not sure what to do.
 
Upvote 0
Basically in my workbook, it opens the dialogue to select a file to link, then it copies the completed form you select to a blank version of that form on a sheet in my workbook. At present, what I have is

<code>
Public Sub Comments()
Dim notes As Integer
notes = 0


Worksheets("the copied worksheet").Activate


If Not IsEmpty("cell1") Then
notes = notes + 1
End If


If Not IsEmpty("cell2") Then
notes = notes + 1
End If


If Not IsEmpty("cell3") Then
notes = notes + 1
End If


If Not IsEmpty("cell4") Then
notes = notes + 1
End If


If Not IsEmpty("cell5") Then
notes = notes + 1
End If

MsgBox notes & " flags were found."


End Sub

</code>

But it's say making notes equal to five even with nothing in those 5 cells. I'm not sure what to do.

How about replacing If Not IsEmpty("cell5") Then with if trim(range("A2"))="" then
Changing A2 to whatever cell it actually is.
 
Upvote 0
Hia
How about
Code:
    Dim Ans As Integer
    
    Ans = WorksheetFunction.CountIf(Range("B11:B16"), "<>")
    MsgBox Ans
Changing the range to suit
 
Upvote 0
Unclebajubjubs,

Welcome to the Board.

We'd need to know how you're copying the data to the worksheet...

@Roderick_E asks a valid question. If your code in post #3 is saying there are 5 notes even when the 5 cells are empty, maybe the copy routine is bringing over formulas or other hidden "data".

Cheers,

tonyyy
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,179
Members
452,615
Latest member
bogeys2birdies

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