Question

Test for empty cell in Excell

Asked by: Net_Worker

I have a workbook with multiple worksheets. Each sheet is a detailed page with dates and times. Sheet 1 has been added as a quick view of each page. The rows of Sheet 1, column A has the name of each of the multiple sheets. I need a formula probably in vba code for Sheet 1 Column B and C. Currently the formula is input into each sheet.

For each populated cell in Sheet 1 column A, look at the value in the row of column A (name). Then go to the named sheet and test for the next available empty cell in Column B, read the value from the cell above insert that into the formula below which will be in column B and C on Sheet 1.

The intention is to move columns C and D from the multiple sheets and to just show the equivalent value on Sheet 1 in Columns B and C. See below.

Current - Sheet 'n'
         A            B              C                                                          D
1 12/06/08  | 12:15  |     =IF(B2="","",(B2+TIME(12,0,0)))   |   =IF(B2="","",B2+(TIME(20,0,0)))

Sheet 1
      A                    B                           C
1| Name   |         Next                  | Local Time
2| sheetn   Value of sheetn:Bn     Value of sheetn:Dn

I hope this makes sense.

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2008-06-15 at 03:53:21ID23486024
Tags

Microsoft

,

Excel

,

Forumla

Topics

Spreadsheet Software

,

Microsoft Office Suite

,

VB Script

Participating Experts
1
Points
250
Comments
26

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Formula to return empty cell
    I have a line chart that shows a fixed time line for 53 weeks and compares values from this year to the previous two years. Since the formulas for the current year will have zeros beyond the current week, the chart plots these results and I get a sudden drop to zero at the c...
  2. Hiding the sheet name of a formula in a cell of a workbook
    I have a very sensitive Excel workbook with Salary Rating Info. The formulas do lookups and other calculations against hidden worksheets within the workbook. I do not want people to see the worksheet references at all in the formula bar of the cell they are in. How can i k...
  3. Replacing parts of a formula and placing a formula in a spec…
    I have a challenge in that I need to replace parts of a formula that is heavily used throughout a 50 worksheet workbook that I have inherited. The current formula reads "I10*VLOOKUP(ReferenceTables!$C$11,ReferenceTables!$B$5:$C$8,2,FALSE)" where the cell reference...
  4. Named cells in workbook in multiple worksheets
    Excel 2003/SP1 XPSP2 My workbook, say workbook B, includes name definitions for the same name but which refer to different cells according to each worksheet. E.g. a cell name defined in worksheet 1 refers to cell <XXnn> and the same cell name defined in worksheet ...
  5. Fill in empty cells
    Hello Experts, I have a worksheet that links to some external data. When I import the data I obviously perform some calcs, however, empty cells are causing me a few errors. How can I fill in the empty cells with 0's either via VBA or a formula depending upon whether there i...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: Net_WorkerPosted on 2008-06-15 at 03:54:25ID: 21788090

Oops, made a little mistake.
Sheet 1
      A                    B                           C
1| Name   |         Next                  | Local Time
2| sheetn   Value of sheetn:Cn     Value of sheetn:Dn

 

by: DerekSchaulandPosted on 2008-06-15 at 06:10:40ID: 21788494

I am not sure I fully understand the question

In column A  you want to list the names of all of the other worksheets in the workbook

then in column B you want to list the next blank cell found on each worksheet or the next time on the listed sheet?

 

by: Net_WorkerPosted on 2008-06-15 at 06:24:40ID: 21788534

Well both really.

I will enter column A in sheet 1 manually and create a sheet with that name. For this example its called sheetn. Then in sheet 1 column B I want to look up the last value in sheetn column B. I then want to put the result of the formula from sheetn columns C and D into sheet 1 colums B and C respectively. Sheetn has many lines in it and I am only interested in the last entry of sheetn when viewing in sheet 1 so I need to look for the last row used.

Example if sheet 1 has the value sheetn in A5 and the last row used in sheetn is 45 then I want the formula to calculate from sheetn:B:45 and display it in sheet1:B:5 and C:5 using the formula for each rows that I have shown above that are currently in sheetn:c and sheetn:d

By the way I also noticed that my original post shows row 1 being used and formula is working on row 2. Obviously this should be the same row.

Hope this make it a bit clearer. If not ask me again. :)

 

by: DerekSchaulandPosted on 2008-06-15 at 07:28:32ID: 21788668

Ok so in sheet 1 we are looking for the following

   Col A |      Col B    | col C
sheetN | sheetn:Bn| Sheetn:Cn

The sheetname cell will likely need a macro or modules in VBA to be achieved in column A: http://www.ozgrid.com/VBA/variable-worksheet-names.htm

but the formula for the value of the last used cell in a column isnt too bad.  In the example below I am referencing sheet2 from sheet1 and assuming column B on sheet 1 will match column B on sheet 2

You will need to use an Array (or CSE) formula to acheive the needed resutl. Note: Array Formulas are entered by keying (or pasting) the formula in and clicking at the end of the formula bar, then pressing Ctrl+Shift+Enter if done correctly Excel will add brackets around the formula.

Formula for Sheet2 Col B is below

=INDEX(Sheet2!B1:Sheet2!B65000,MAX(IF(LEN(Sheet2!B1:Sheet2!B65000)>0,ROW(Sheet2!B1:Sheet2!B65000),0)),1)

Hope this helps

Derek

 

by: Net_WorkerPosted on 2008-06-15 at 08:24:51ID: 21788813

I'll take a look but to clarify as it may alter your response) your close but not quite.

On sheet 1 I am look for
ColA     |                                   ColB        |                          ColC
sheetN | =sheetN!(Bn+TIME(12,0,0)) | =I(sheetN!Bn+(TIME(20,0,0))

Nothing actually needs to be done to sheetN. I need to somehow make the sheet name a variable read from the contents of sheet1!colA:rowN and use that variable to get a value to insert into the formula for each of colB and colC above, using the last line in sheetN!colB. I figured checking for a null value and moving up 1 place to get the value. How to code the variable and the null check sequence, I am not sure.

 

by: Net_WorkerPosted on 2008-06-15 at 08:26:11ID: 21788816

DOH! I should proof read before posting.

ColA     |                                   ColB        |                          ColC
sheetN | =sheetN!(Bn+TIME(12,0,0)) | =sheetN!Bn+(TIME(20,0,0))

Thats better. I am sure you would have picked it up anyway.

 

by: DerekSchaulandPosted on 2008-06-15 at 15:24:21ID: 21789932

Aren't you getting the values for columns B and C from another sheet?

that is the only part of the previous formula that references sheet (n)

It is checking the sheet for the last value in a column and returning that value to sheet 1 column B or C

 

by: Net_WorkerPosted on 2008-06-15 at 22:39:00ID: 21790968

I have used the formula on a test as I have not yet worked out how to use the dynamic reference however, I have tried to work it out but this formula gives a result of 0 but should be 09:27. Both the referenced cell and the used cell are formatted as time. Any clues?

 

by: DerekSchaulandPosted on 2008-06-16 at 06:01:20ID: 21793124

When you select the cell containing the formula on sheet 1 does the formula have brackets around it like this

{
=INDEX(Sheet2!B1:Sheet2!B65000,MAX(IF(LEN(Sheet2!B1:Sheet2!B65000)>0,ROW(Sheet2!B1:Sheet2!B65000),0)),1)}

or does it just display the formula?  Without the brackets the calculation will not work as it needs to be an array formula.

Also you will need to format the cells in sheet 1 containing the formula as time so they will correctly display the value when returned.

 

by: Net_WorkerPosted on 2008-06-16 at 07:12:34ID: 21793761

No parenthesis on the formula. I added them and now it shows the formula in the cell. The cell is formatted as time already in both sheets.

 

by: Net_WorkerPosted on 2008-06-16 at 07:15:09ID: 21793795

Sorry it doesn't display the formula it errors on the parenthesis.

 

by: DerekSchaulandPosted on 2008-06-16 at 07:24:31ID: 21793879

The brackets should not need to be typed in... when you paste the formula instead of hitting enter to insert it, press Control+Shift+Enter

that should add the brackets and create an array formula

 

by: Net_WorkerPosted on 2008-06-16 at 07:28:41ID: 21793926

Yes that worked. Now how to make that an automated process? Sheets are added and removed daily and so sheet1 needs to be easy to edit and update.

 

by: DerekSchaulandPosted on 2008-06-16 at 08:13:23ID: 21794392

To get a list of worksheet names that is dynamic you will probably need a macro fired on load.

This link explains how that works and also has a downloadable example

http://www.ozgrid.com/News/oct-2006.htm#ExcelTips

 

by: Net_WorkerPosted on 2008-06-16 at 10:25:28ID: 21795633

I think with this guide I should be able to work the required code. I just have concern about the ctrl+shift+enter sequence to create the array. When I entered the parenthesis it did not create the array so how do I do that in code?

 

by: DerekSchaulandPosted on 2008-06-16 at 10:30:49ID: 21795681

I would copy and paste the formula all the way down the columns as needed for ease of use

however to add this to a macro you could do something like

cells(x).formulaarray= "<Formula goes here>"

within the macro generating the sheet names to place the value fetch into the row as the sheet name is populated

 

by: Net_WorkerPosted on 2008-06-16 at 22:36:39ID: 21800105

OK we're making progress. I have followed the guide you have given me and the dynamic list is all working great but it only works if I create a new blank worksheet. I need the function to work by copying a template. The template has a preconfigured chart based on the data that is entered into it. It also uses panes and the chart is static at the top of the sheet but aside from that it is a standard worksheet.

The guide states that this only works on standard worksheets. What does that definition mean?

From here I will need to create a macro button that will;
1.Open a dialog prompt to enter the new sheet name
2.Copy and rename the template from the dialog variable
3.Add the sheet name to the dynamic list
4.Hyperlink that name in the list to the sheet.

Can you offer any code snippets that can do what I need based on the guide you have given me.

 

by: Net_WorkerPosted on 2008-06-17 at 01:24:36ID: 21800809

Also from your last post, could you give me an example? I get what you mean but not sure how the code would look.

 

by: DerekSchaulandPosted on 2008-06-17 at 06:44:03ID: 21802869

This is the best example I could find for getting an array formula from a macro to the screen

Range("b3").Select
Selection.FormulaArray = "=MIN(if(a2:a100>0,a2:a100))"

Cell B3 on sheet containing macro will have the value created by the array formula listed above.  Does not require brackets in Macro because it sets the formulaArray property of the selection object.  The selection object becomes cell b3.

As for the macro:

1. Range("A1") = InputBox("Enter value here") will put the text entered into the input box in cell A1

2. something like the following:

dim varname as string

   Range("A1") = varname

Worksheets(2).Name = varname

creates a variable, then you could populate the variable with varname = inputbox("enter data") and use the variable to populate A1 and the sheetname.  the 2 specifies worksheet 2 of the worksheets array, something like

dim i as int

i = 1

x = worksheets.count - i

worksheets(x).name = varname should rename the worksheet that is next to last each time it is executed perhaps in a for loop.

3. could integrate this macro into dynamic list macro so they all happen together... perhaps using the hyperlink formula to get the link

I was thinking.. you might create the dynamic list in a different column, like ZZ and hide it, then use the hyperlink() formula to link to the sheet with the name in column ZZ..

 

by: Net_WorkerPosted on 2008-06-17 at 06:55:51ID: 21803026

I'll give that a try. Any ideas on what I need to change to make it work copying my template?

 

by: DerekSchaulandPosted on 2008-06-17 at 06:58:10ID: 21803054

might be able to do a move/copy

leave the template sheet as last in workbook, the use macro coding to create the new sheet and name it, and then copy the template contents only into new named sheet

 

by: Net_WorkerPosted on 2008-06-17 at 07:01:59ID: 21803110

I tried a move/copy which failed. If I create a new worksheet it shows up in the list fine. Would I be best to use the macro recorder to select all > copy > past or can this be done in code. Sorry for all the lame questions but I haven't done any VBA for about 4 years and I am very rusty. I remember that mouse clicks did not get recorded with the macro recorder. Is that still the case?

 

by: DerekSchaulandPosted on 2008-06-17 at 07:51:41ID: 21803640

You could use VBA to build a macro...

when it creates the sheet, then copy the template and paste to the newly created sheet.  If you leave the template as the last sheet, maybe called template it should be able to whip right through it each time the macro is fired.

I would not use the macro recorder... since you already have a macro built for the dynamic sheet names you could add on to it or add another macro action for a button click to fire the copy/paste

something like

dim iCount as integer

icount = worksheets.count

worksheets(template sheet number).copy After:=worksheets(icount)

should plop a copy of the sheet after the last sheet... might be able to paste into existing sheet or rename the newly copied sheet to something useful and use that in the dynamic list

 

by: Net_WorkerPosted on 2008-06-17 at 20:23:13ID: 21809764

Yes but thats what I mean. With the code from the website you gave me, it doesn't populate the list if I do copy/move. I was going to do exactly what you said just above but thats where I come unstuck. Is there a function that can select the entire template contents and copy into a new blank sheet? Unless I am doing it wrong I think this will be the only way while still using the dynamic list.

 

by: DerekSchaulandPosted on 2008-06-18 at 08:16:55ID: 21813822

Sure you can copy and paste in a macro

an example is below:

Select the cells used in the worksheet that contains the template

Range("a1:y39").Select

'Copy that selection
Selection.Copy

'Select the worksheet to paste the selection into (worksheets(i) where i is the number of the newest dynamic sheet)
Worksheets(i).Select

'select the first cell of the dynamic sheet so you have somewhere to paste your templae
Range("a1").Select

'paste the clipboard content into the now active sheet
ActiveSheet.Paste

Note the range I chose was for an example. you would use a range that covers the entire template

 

by: Net_WorkerPosted on 2008-06-22 at 04:23:07ID: 31467321

I still haven't quite finished it but you got me on the right track.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...