473,692 Members | 2,592 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getting value from another column based on a status column, with a twist

24 New Member
Hi,

I am wondering how to get a value from one column based on another, using visual basic for applications. Here are the criteria: The first column contains status and we want the next row in the list after the last row that contains "completed" .

The second column contains a value that I want to use in a chart. So, in other words, I want to automatically find the value in the second column that is in the row after the LAST row with "completed" for status. The records are in order in the worksheet. Oh, I gave it away, I am using Excel :-)


Thanks in advance for your time and help.
Jan 24 '07 #1
1 1316
Killer42
8,435 Recognized Expert Expert
Here's a bit of a silly-looking little macro, which demonstrates a simple (though probably rather inefficient) way of finding the last "completed" in column C. To get the row after the last one, you could just add one to FoundCell.Row.
Expand|Select|Wrap|Line Numbers
  1. Sub aaaaa()
  2.   Dim MyCell As Range, FoundCell As Range, FoundPos As Long
  3.   For Each MyCell In Range("C:C")
  4.     If MyCell.Value = "completed" Then
  5.       FoundPos = MyCell.Row
  6.       Debug.Print FoundPos
  7.       Set FoundCell = MyCell
  8.     End If
  9.   Next
  10.  
  11.   If FoundPos > 0 Then
  12.     Debug.Print "Last one found was at:"; FoundCell.Address
  13.   End If
  14. End Sub
Jan 29 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

303
17624
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b. Yahoo store was originally written in Lisp. c. Emacs The issues with these will probably come up, so I might as well mention them myself (which will also make this a more balanced
2
5240
by: daddygiles | last post by:
I am trying to select a group of records based on a parameter value passed to the db from a web page. The value comes in as @Status and has a list of statusID's: (1,2,5,9) I've tried to use "Where table.status IN (Select * from @Status AS ValueList)" And also tried "Where table.status IN (@Status)" And neither worked. Any suggestions?
3
6090
by: Ronny Sigo | last post by:
Hello all, On my form I have an unbound combobox based on a query displaying two rows. The rows are : 1) Zipcode (Leftmost (In the query this field is sorted ascending 2 City The BoundColumn property is set to 2, because the value of Citymust appear in another control When selecting a unique zipcode there is no problem, it does what is expected but ...
8
18368
by: Lyn | last post by:
Hi, Can anyone tell me how the initial value displayed in Combo Box is determined when a form is opened? I am loading the dropdown from one field ("CategoryName") of a table, with "ORDER BY ". The values in the dropdown are loaded in the correct order, but the initial value is not the first row of the dropdown as I expected. The field "CategoryName" is not the primary key for the table -- the PK is
6
2245
by: melanieab | last post by:
Hi, Easy question. It seems to me that I'm following the examples correctly, but apparently I'm not. I'm trying to retrieve the data from a row called "row" and a column called "File". This is what I have: (xFile is the int value in column File and tCat is the table) First I try: xFile = int.Parse((tCat.Rows).ToString()); Another example I found:
5
2966
by: Rex | last post by:
Hi, I want to change a value in one table depending on the value(s) in another table. I am trying to achieve this in a form. to elaborate I have a many-to-many relationship between tables Forms and Family and the associate table is called Forms_Family. Forms_Family have fields "dateSent" and "dateReceived". The Family table has a field called
1
3195
by: simbarashe | last post by:
Hie could someone please help me with getting and using the current page url. I have a function that gets the url, I want to use it with header(location : XXX) but it wont work. The code is as follows: The code below is for the first page:session_start is in line 3 <link href="css/jobSheet.css" rel="stylesheet" type="text/css" /> session_start();
33
11849
by: JamesB | last post by:
I am writing a service that monitors when a particular app is started. Works, but I need to get the user who is currently logged in, and of course Environment.UserName returns the service logon (NT_AUTHORITY\SYSTEM). I understand that when the service starts, no user may be logged in, but that's ok, as the app I am monitoring can only be run by a logged in user. Do I need to use WMI to get the user context of Explorer.exe or is there a...
4
3424
by: JHite | last post by:
I am using Access 2003 on Windows XP. This is a simple database that contains “tblStaffers” containing names of the office staffers, “tblProjects” containing names of the office projects, and “tblStatusReports” containing the “StafferID” (link to Staffer table), the “ProjectID” (link to Projects table), a “Date” field, and a “Notes” field. There is a main form, “frmStaffEntry,” with a subform, “frmStatusReports,” for a user to...
0
8611
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8547
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9090
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8812
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8810
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4329
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2984
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2242
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1962
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.