MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Apr 10th, 2002, 01:42 PM   #1
Todd_M
Board Regular
 
Join Date: Feb 2002
Posts: 117
Default

Hi-

matchcol = Cells(x, "cb").End(xlToLeft).Column

This code finds the next empty cell to the left of column "CB". But if theres a formula (even though the cell is blank)the code chooses that cell. How can I rearange that code so that it wont reconize a formula in the cell, but just the first cell with actuall text?
Todd_M is offline   Reply With Quote
Old Apr 10th, 2002, 02:21 PM   #2
Al Chara
MrExcel MVP
 
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
Default

If there is always this cell with a formula at the end then you can just offset over 1:

matchcol = Cells(x, "cb").End(xlToLeft).Columns.Offset(0, -1).Select

or put a loop after it:

matchcol = Cells(x, "cb").End(xlToLeft).Columns.Select
Do While ActiveCell.Formula <> ""
On Error GoTo 1
ActiveCell.Offset(0, -1).Select
Loop
1



_________________
Hope this helps.
Kind regards, Al.

[ This Message was edited by: Al Chara on 2002-04-10 13:26 ]
Al Chara is offline   Reply With Quote
Old Apr 10th, 2002, 03:18 PM   #3
Todd_M
Board Regular
 
Join Date: Feb 2002
Posts: 117
Default

Al- Thanks for responding, All the cells that this code uses contian formulas. The formula pulls text from another part of the sheet. (ex: cell BX3 has a formula that reads =T3) So if cell T3 contains a number then that duplicate number is copied in cell BX3. All cells that the code uses consists of these type formulas. The cells maybe blank, but the code doesnt read it that way. How would you suggest that I could still use:


matchcol = Cells(x, "cb").End(xlToLeft).Column

and find the next empty cell (even though theres a formula in it)

Todd_M is offline   Reply With Quote
Old Apr 10th, 2002, 03:34 PM   #4
Al Chara
MrExcel MVP
 
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
Default

Quote:
Cells(x, "cb").select
Do While ActiveCell.Formula <> ""
On Error GoTo 1
ActiveCell.Offset(0, -1).Select
Loop
1
Won't think work for you.
__________________
Kind regards,

Al Chara
Al Chara is offline   Reply With Quote
Old Apr 10th, 2002, 03:49 PM   #5
Todd_M
Board Regular
 
Join Date: Feb 2002
Posts: 117
Default

No unfortanatly it wont, thanks anyway
Todd_M is offline   Reply With Quote
Old Apr 10th, 2002, 03:53 PM   #6
Al Chara
MrExcel MVP
 
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
Default

Explain, why it won't work. I can edit to fit your situation.
Al Chara is offline   Reply With Quote
Old Apr 10th, 2002, 04:06 PM   #7
Todd_M
Board Regular
 
Join Date: Feb 2002
Posts: 117
Default

Ok heres the full code:


Private Sub CommandButton6_Click()
Dim lastrow As Long, x As Long
Dim matchday As Integer, matchcol As Integer
Dim myarr(1 To 7)

matchday = WorksheetFunction.Match(Format(Date, "dddd"), Rows("1:1"), 0)

lastrow = Cells(Rows.Count, "bt").End(xlUp).Row
For x = 2 To lastrow
matchcol = Cells(x, "cb").End(xlToLeft).Column

If matchcol <> matchday Then GoTo E
MsgBox Cells(x, 72) & " gets paid today."
E:
Next x
End Sub


What Im try to acomplish is a work schedual for employees. The schedual is actually written in another part of the same sheet. I cant use the code on the original part becouse theres to many varibles and spaces. So what im trying to do is consolidate the important info in another part of the sheet by just having those cells in question using a formula (=T1). The code works well when I manualy enter numbers(Times), but the times have to be posted automatically from the first part of the sheet(using the formulas). Thats why the section of cells that the code reads all contain formulas, even though some cells are blank.
Todd_M is offline   Reply With Quote
Old Apr 10th, 2002, 04:46 PM   #8
Al Chara
MrExcel MVP
 
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
Default

I apologize, I was reading what you wanted to do completely backwards. I think this is closer to a solution. The do loop works, I didn't test the rest.

Code:
Private Sub CommandButton6_Click()
Dim lastrow As Long, x As Long
Dim matchday As Integer, matchcol As Integer
Dim myarr(1 To 7)

matchday = WorksheetFunction.Match(Format(Date, "dddd"), Rows("1:1"), 0)

lastrow = Cells(Rows.Count, "bt").End(xlUp).Row
For x = 2 To lastrow
Cells(x, "cb").Select
Do
On Error GoTo 1
ActiveCell.Offset(0, -1).Select
Loop Until Application.WorksheetFunction.IsNumber(ActiveCell.Value) = True And ActiveCell.Value <> 0
1
If matchcol <> matchday Then GoTo E
MsgBox Cells(x, 72) & " gets paid today."
E:
Next x
End Sub
_________________
Hope this helps.
Kind regards, Al.

[ This Message was edited by: Al Chara on 2002-04-10 15:47 ]

[ This Message was edited by: Al Chara on 2002-04-10 15:48 ]
Al Chara is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On

Forum Jump


All times are GMT -4. The time now is 04:46 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes