PC Review


Reply
Thread Tools Rate Thread

check certain cells for data before saving file

 
 
Anthony
Guest
Posts: n/a
 
      2nd Jul 2008
Hi all,

I have a macro used to save a worksheet, its placed on the DATA sheet.
is there a way so that when the user clicks this button each row 12:200 is
checked for empty cells in that row (cells B:P). If a row is found the ref
number in column A of each row is placed into next available row in Sheet3

For example :
A12 = 12345
A13 = 6789
A14 = 9876
A15 = 54321

the DATA sheet is populated with various data in rows 12:15
it is found that B12, L12, E14,F14,P15 all have no data, so the values of
A12,A14 and A15 are placed into next row in Sheet3

Result in sheet3

A2= 12345 (valuse of A12 in DATA Sheet)
A3= 9876 (value of A14 in DATA Sheet)
A4= 54321 (value of A15 in DATA sheet)

Finally a message box to state there is missing data, for example

"there is missing data from refs 12345 , 9876 , 54321" ie the list pasted
into sheet3

Hope somebody can help and understand my goal(s)

Many thanks in advance
 
Reply With Quote
 
 
 
 
vezerid
Guest
Posts: n/a
 
      2nd Jul 2008
This macro does, I believe, what you are asking for:

Sub CheckMissing()
rn = 2
cnt = 0
For i = 12 To 200
For j = 2 To 16
If Sheets("DATA").Cells(i, j) = "" Then
j = 17
Sheets("sheet3").Cells(rn, 1) = Sheets("DATA").Cells(i, 1)
rn = rn + 1
If cnt = 0 Then
msg = "There is missing data from refs " &
Sheets("DATA").Cells(i, 1)
Else
msg = msg & ", " & Sheets("DATA").Cells(i, 1)
End If
cnt = cnt + 1
End If
Next j
Next i
If cnt = 0 Then
MsgBox "All rows filled"
Else
MsgBox msg
End If
End Sub


HTH
Kostis Vezerides
On Jul 2, 5:55 pm, Anthony <Anth...@discussions.microsoft.com> wrote:
> Hi all,
>
> I have a macro used to save a worksheet, its placed on the DATA sheet.
> is there a way so that when the user clicks this button each row 12:200 is
> checked for empty cells in that row (cells B:P). If a row is found the ref
> number in column A of each row is placed into next available row in Sheet3
>
> For example :
> A12 = 12345
> A13 = 6789
> A14 = 9876
> A15 = 54321
>
> the DATA sheet is populated with various data in rows 12:15
> it is found that B12, L12, E14,F14,P15 all have no data, so the values of
> A12,A14 and A15 are placed into next row in Sheet3
>
> Result in sheet3
>
> A2= 12345 (valuse of A12 in DATA Sheet)
> A3= 9876 (value of A14 in DATA Sheet)
> A4= 54321 (value of A15 in DATA sheet)
>
> Finally a message box to state there is missing data, for example
>
> "there is missing data from refs 12345 , 9876 , 54321" ie the list pasted
> into sheet3
>
> Hope somebody can help and understand my goal(s)
>
> Many thanks in advance


 
Reply With Quote
 
Anthony
Guest
Posts: n/a
 
      2nd Jul 2008
Thanks for ur help
2 questions if I may?

1) is it possible to omit the check from column O of the check ie alow this
to be unpopulated
2) is it possible to remove the ,,,,,,,,,,,,,,,,,,,,,,,,,, at the end of the
msgbox for the unused rows??

thanks again

"vezerid" wrote:

> This macro does, I believe, what you are asking for:
>
> Sub CheckMissing()
> rn = 2
> cnt = 0
> For i = 12 To 200
> For j = 2 To 16
> If Sheets("DATA").Cells(i, j) = "" Then
> j = 17
> Sheets("sheet3").Cells(rn, 1) = Sheets("DATA").Cells(i, 1)
> rn = rn + 1
> If cnt = 0 Then
> msg = "There is missing data from refs " &
> Sheets("DATA").Cells(i, 1)
> Else
> msg = msg & ", " & Sheets("DATA").Cells(i, 1)
> End If
> cnt = cnt + 1
> End If
> Next j
> Next i
> If cnt = 0 Then
> MsgBox "All rows filled"
> Else
> MsgBox msg
> End If
> End Sub
>
>
> HTH
> Kostis Vezerides
> On Jul 2, 5:55 pm, Anthony <Anth...@discussions.microsoft.com> wrote:
> > Hi all,
> >
> > I have a macro used to save a worksheet, its placed on the DATA sheet.
> > is there a way so that when the user clicks this button each row 12:200 is
> > checked for empty cells in that row (cells B:P). If a row is found the ref
> > number in column A of each row is placed into next available row in Sheet3
> >
> > For example :
> > A12 = 12345
> > A13 = 6789
> > A14 = 9876
> > A15 = 54321
> >
> > the DATA sheet is populated with various data in rows 12:15
> > it is found that B12, L12, E14,F14,P15 all have no data, so the values of
> > A12,A14 and A15 are placed into next row in Sheet3
> >
> > Result in sheet3
> >
> > A2= 12345 (valuse of A12 in DATA Sheet)
> > A3= 9876 (value of A14 in DATA Sheet)
> > A4= 54321 (value of A15 in DATA sheet)
> >
> > Finally a message box to state there is missing data, for example
> >
> > "there is missing data from refs 12345 , 9876 , 54321" ie the list pasted
> > into sheet3
> >
> > Hope somebody can help and understand my goal(s)
> >
> > Many thanks in advance

>
>

 
Reply With Quote
 
vezerid
Guest
Posts: n/a
 
      2nd Jul 2008
For question #1: Yes it is, here is the modified routine:

Sub CheckMissing()
rn = 2
cnt = 0
For i = 12 To 200
For j = 2 To 16
If j <> 15 Then
If Sheets("DATA").Cells(i, j) = "" Then
j = 17
Sheets("sheet3").Cells(rn, 1) =
Sheets("DATA").Cells(i, 1)
rn = rn + 1
If cnt = 0 Then
msg = "There is missing data from refs " &
Sheets("DATA").Cells(i, 1)
Else
msg = msg & ", " & Sheets("DATA").Cells(i, 1)
End If
cnt = cnt + 1
End If
End If
Next j
Next i
If cnt = 0 Then
MsgBox "All rows filled"
Else
MsgBox msg
End If
End Sub

For question #2, I don't understand. Do you not wish the message to
appear? Do you not wish the offending refs to be listed in the
message?

Kostis

On Jul 2, 8:13 pm, Anthony <Anth...@discussions.microsoft.com> wrote:
> Thanks for ur help
> 2 questions if I may?
>
> 1) is it possible to omit the check from column O of the check ie alow this
> to be unpopulated
> 2) is it possible to remove the ,,,,,,,,,,,,,,,,,,,,,,,,,, at the end of the
> msgbox for the unused rows??
>
> thanks again
>
> "vezerid" wrote:
> > This macro does, I believe, what you are asking for:

>
> > Sub CheckMissing()
> > rn = 2
> > cnt = 0
> > For i = 12 To 200
> > For j = 2 To 16
> > If Sheets("DATA").Cells(i, j) = "" Then
> > j = 17
> > Sheets("sheet3").Cells(rn, 1) = Sheets("DATA").Cells(i, 1)
> > rn = rn + 1
> > If cnt = 0 Then
> > msg = "There is missing data from refs " &
> > Sheets("DATA").Cells(i, 1)
> > Else
> > msg = msg & ", " & Sheets("DATA").Cells(i, 1)
> > End If
> > cnt = cnt + 1
> > End If
> > Next j
> > Next i
> > If cnt = 0 Then
> > MsgBox "All rows filled"
> > Else
> > MsgBox msg
> > End If
> > End Sub

>
> > HTH
> > Kostis Vezerides
> > On Jul 2, 5:55 pm, Anthony <Anth...@discussions.microsoft.com> wrote:
> > > Hi all,

>
> > > I have a macro used to save a worksheet, its placed on the DATA sheet.
> > > is there a way so that when the user clicks this button each row 12:200 is
> > > checked for empty cells in that row (cells B:P). If a row is found the ref
> > > number in column A of each row is placed into next available row in Sheet3

>
> > > For example :
> > > A12 = 12345
> > > A13 = 6789
> > > A14 = 9876
> > > A15 = 54321

>
> > > the DATA sheet is populated with various data in rows 12:15
> > > it is found that B12, L12, E14,F14,P15 all have no data, so the values of
> > > A12,A14 and A15 are placed into next row in Sheet3

>
> > > Result in sheet3

>
> > > A2= 12345 (valuse of A12 in DATA Sheet)
> > > A3= 9876 (value of A14 in DATA Sheet)
> > > A4= 54321 (value of A15 in DATA sheet)

>
> > > Finally a message box to state there is missing data, for example

>
> > > "there is missing data from refs 12345 , 9876 , 54321" ie the list pasted
> > > into sheet3

>
> > > Hope somebody can help and understand my goal(s)

>
> > > Many thanks in advance


 
Reply With Quote
 
Anthony
Guest
Posts: n/a
 
      2nd Jul 2008
,Thanks , I'll try the new code,

Question 2.....
Once the code is run the msg box appears with the message like this..

There is missing data from refs
45677,2345,12344,67678,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

I don't want the ',,,,,,,,,,,,,,,,,,,,,,' to appear

thanks
"vezerid" wrote:

> For question #1: Yes it is, here is the modified routine:
>
> Sub CheckMissing()
> rn = 2
> cnt = 0
> For i = 12 To 200
> For j = 2 To 16
> If j <> 15 Then
> If Sheets("DATA").Cells(i, j) = "" Then
> j = 17
> Sheets("sheet3").Cells(rn, 1) =
> Sheets("DATA").Cells(i, 1)
> rn = rn + 1
> If cnt = 0 Then
> msg = "There is missing data from refs " &
> Sheets("DATA").Cells(i, 1)
> Else
> msg = msg & ", " & Sheets("DATA").Cells(i, 1)
> End If
> cnt = cnt + 1
> End If
> End If
> Next j
> Next i
> If cnt = 0 Then
> MsgBox "All rows filled"
> Else
> MsgBox msg
> End If
> End Sub
>
> For question #2, I don't understand. Do you not wish the message to
> appear? Do you not wish the offending refs to be listed in the
> message?
>
> Kostis
>
> On Jul 2, 8:13 pm, Anthony <Anth...@discussions.microsoft.com> wrote:
> > Thanks for ur help
> > 2 questions if I may?
> >
> > 1) is it possible to omit the check from column O of the check ie alow this
> > to be unpopulated
> > 2) is it possible to remove the ,,,,,,,,,,,,,,,,,,,,,,,,,, at the end of the
> > msgbox for the unused rows??
> >
> > thanks again
> >
> > "vezerid" wrote:
> > > This macro does, I believe, what you are asking for:

> >
> > > Sub CheckMissing()
> > > rn = 2
> > > cnt = 0
> > > For i = 12 To 200
> > > For j = 2 To 16
> > > If Sheets("DATA").Cells(i, j) = "" Then
> > > j = 17
> > > Sheets("sheet3").Cells(rn, 1) = Sheets("DATA").Cells(i, 1)
> > > rn = rn + 1
> > > If cnt = 0 Then
> > > msg = "There is missing data from refs " &
> > > Sheets("DATA").Cells(i, 1)
> > > Else
> > > msg = msg & ", " & Sheets("DATA").Cells(i, 1)
> > > End If
> > > cnt = cnt + 1
> > > End If
> > > Next j
> > > Next i
> > > If cnt = 0 Then
> > > MsgBox "All rows filled"
> > > Else
> > > MsgBox msg
> > > End If
> > > End Sub

> >
> > > HTH
> > > Kostis Vezerides
> > > On Jul 2, 5:55 pm, Anthony <Anth...@discussions.microsoft.com> wrote:
> > > > Hi all,

> >
> > > > I have a macro used to save a worksheet, its placed on the DATA sheet.
> > > > is there a way so that when the user clicks this button each row 12:200 is
> > > > checked for empty cells in that row (cells B:P). If a row is found the ref
> > > > number in column A of each row is placed into next available row in Sheet3

> >
> > > > For example :
> > > > A12 = 12345
> > > > A13 = 6789
> > > > A14 = 9876
> > > > A15 = 54321

> >
> > > > the DATA sheet is populated with various data in rows 12:15
> > > > it is found that B12, L12, E14,F14,P15 all have no data, so the values of
> > > > A12,A14 and A15 are placed into next row in Sheet3

> >
> > > > Result in sheet3

> >
> > > > A2= 12345 (valuse of A12 in DATA Sheet)
> > > > A3= 9876 (value of A14 in DATA Sheet)
> > > > A4= 54321 (value of A15 in DATA sheet)

> >
> > > > Finally a message box to state there is missing data, for example

> >
> > > > "there is missing data from refs 12345 , 9876 , 54321" ie the list pasted
> > > > into sheet3

> >
> > > > Hope somebody can help and understand my goal(s)

> >
> > > > Many thanks in advance

>
>

 
Reply With Quote
 
vezerid
Guest
Posts: n/a
 
      3rd Jul 2008
The commas appear b/c you don't have data all the way down to 200, as
indicated in your original post. I changed the code to start checking
from row 2 and as far down as there are data (assuming no empty rows).

Sub CheckMissing()
rn = 2
i = 2
cnt = 0
While Sheets("DATA").Cells(i, 1) <> ""
For j = 2 To 16
If j <> 15 Then
If Sheets("DATA").Cells(i, j) = "" Then
j = 17
Sheets("sheet3").Cells(rn, 1) =
Sheets("DATA").Cells(i, 1)
rn = rn + 1
If cnt = 0 Then
msg = "There is missing data from refs " &
Sheets("DATA").Cells(i, 1)
Else
msg = msg & ", " & Sheets("DATA").Cells(i, 1)
End If
cnt = cnt + 1
End If
End If
Next j
i = i + 1
Wend
If cnt = 0 Then
MsgBox "All rows filled"
Else
MsgBox msg
End If
End Sub

HTW
Kostis

On Jul 2, 9:02 pm, Anthony <Anth...@discussions.microsoft.com> wrote:
> ,Thanks , I'll try the new code,
>
> Question 2.....
> Once the code is run the msg box appears with the message like this..
>
> There is missing data from refs
> 45677,2345,12344,67678,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
>
> I don't want the ',,,,,,,,,,,,,,,,,,,,,,' to appear
>
> thanks
>
> "vezerid" wrote:
> > For question #1: Yes it is, here is the modified routine:

>
> > Sub CheckMissing()
> > rn = 2
> > cnt = 0
> > For i = 12 To 200
> > For j = 2 To 16
> > If j <> 15 Then
> > If Sheets("DATA").Cells(i, j) = "" Then
> > j = 17
> > Sheets("sheet3").Cells(rn, 1) =
> > Sheets("DATA").Cells(i, 1)
> > rn = rn + 1
> > If cnt = 0 Then
> > msg = "There is missing data from refs " &
> > Sheets("DATA").Cells(i, 1)
> > Else
> > msg = msg & ", " & Sheets("DATA").Cells(i, 1)
> > End If
> > cnt = cnt + 1
> > End If
> > End If
> > Next j
> > Next i
> > If cnt = 0 Then
> > MsgBox "All rows filled"
> > Else
> > MsgBox msg
> > End If
> > End Sub

>
> > For question #2, I don't understand. Do you not wish the message to
> > appear? Do you not wish the offending refs to be listed in the
> > message?

>
> > Kostis

>
> > On Jul 2, 8:13 pm, Anthony <Anth...@discussions.microsoft.com> wrote:
> > > Thanks for ur help
> > > 2 questions if I may?

>
> > > 1) is it possible to omit the check from column O of the check ie alow this
> > > to be unpopulated
> > > 2) is it possible to remove the ,,,,,,,,,,,,,,,,,,,,,,,,,, at the end of the
> > > msgbox for the unused rows??

>
> > > thanks again

>
> > > "vezerid" wrote:
> > > > This macro does, I believe, what you are asking for:

>
> > > > Sub CheckMissing()
> > > > rn = 2
> > > > cnt = 0
> > > > For i = 12 To 200
> > > > For j = 2 To 16
> > > > If Sheets("DATA").Cells(i, j) = "" Then
> > > > j = 17
> > > > Sheets("sheet3").Cells(rn, 1) = Sheets("DATA").Cells(i, 1)
> > > > rn = rn + 1
> > > > If cnt = 0 Then
> > > > msg = "There is missing data from refs " &
> > > > Sheets("DATA").Cells(i, 1)
> > > > Else
> > > > msg = msg & ", " & Sheets("DATA").Cells(i, 1)
> > > > End If
> > > > cnt = cnt + 1
> > > > End If
> > > > Next j
> > > > Next i
> > > > If cnt = 0 Then
> > > > MsgBox "All rows filled"
> > > > Else
> > > > MsgBox msg
> > > > End If
> > > > End Sub

>
> > > > HTH
> > > > Kostis Vezerides
> > > > On Jul 2, 5:55 pm, Anthony <Anth...@discussions.microsoft.com> wrote:
> > > > > Hi all,

>
> > > > > I have a macro used to save a worksheet, its placed on the DATA sheet.
> > > > > is there a way so that when the user clicks this button each row 12:200 is
> > > > > checked for empty cells in that row (cells B:P). If a row is found the ref
> > > > > number in column A of each row is placed into next available row in Sheet3

>
> > > > > For example :
> > > > > A12 = 12345
> > > > > A13 = 6789
> > > > > A14 = 9876
> > > > > A15 = 54321

>
> > > > > the DATA sheet is populated with various data in rows 12:15
> > > > > it is found that B12, L12, E14,F14,P15 all have no data, so the values of
> > > > > A12,A14 and A15 are placed into next row in Sheet3

>
> > > > > Result in sheet3

>
> > > > > A2= 12345 (valuse of A12 in DATA Sheet)
> > > > > A3= 9876 (value of A14 in DATA Sheet)
> > > > > A4= 54321 (value of A15 in DATA sheet)

>
> > > > > Finally a message box to state there is missing data, for example

>
> > > > > "there is missing data from refs 12345 , 9876 , 54321" ie the list pasted
> > > > > into sheet3

>
> > > > > Hope somebody can help and understand my goal(s)

>
> > > > > Many thanks in advance


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Check Data before Saving. Nad Microsoft Access 2 15th Jun 2009 03:11 PM
Excel 2000 Standard not saving data when saving file D.Watt Microsoft Excel Crashes 0 5th Dec 2007 03:53 PM
Check for valid file name before saving mpfohl@hotmail.com Microsoft Access Forms 1 13th Mar 2007 02:19 AM
Check for file before saving Striker Microsoft Excel Programming 1 21st Jul 2006 02:22 PM
Saving field data on check box Jim Microsoft Access Reports 1 11th Nov 2003 09:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:47 PM.