基于在另一个工作表中匹配的连接姓名和生日的条件格式化名称

huangapple go评论60阅读模式
英文:

Conditional Formatting of Names Based on Matching Concatenated Name and Birthday in another sheet

问题

我正在尝试在多个工作表中突出显示生日等于今天的学生,并寻求一些建议。在名为StudentInfo的工作表中,有许多列:FirstName(B)、LastName(C)、FullName(D)、Advisor(E)、Locker(F)、Birthday(G)等。列FullName是列B和C的串联,例如=C2 & ", " & B2(显示姓氏,名字)。因此,这是一个计算值而不是字符串。此外,我已将列FullName(D)中的范围命名为“StudentList”,并将列Birthday(G)中的范围命名为“Birthdays”。

在其他工作表中,我使用相同的格式输入学生姓名:LastName, FirstName(仅为字符串值,没有串联)。我想要做的是在这些其他工作表中,使用条件格式突出显示满足两个条件的学生姓名单元格:单元格=StudentInfo!StudentList 并且 Birthdays = 今天。我可以轻松在StudentInfo工作表上使生日提醒的条件格式工作,但在其他工作表中突出显示学生姓名的条件格式逻辑令我困扰。类似于...
=B4=StudentList AND DATEVALUE(TEXT(Birthdays,"m/d")=TODAY())

是否可以在这种方式中在另一个工作表中使用条件格式?任何帮助都将不胜感激。谢谢。

英文:

I'm trying to highlight students whose birthdays = TODAY across multiple sheets and am seeking some advice. In a sheet named StudentInfo, there are a number of columns: FirstName (B), LastName (C), FullName (D), Advisor (E), Locker (F), Birthday (G), etc. Col FullName is a concatenation of cols B and C, such as =C2 &", "&B2 (showing Lastname, Firstname). So, this is a calculated value instead of a string. Also, I've named the range in col FullName (D) as "StudentList" and the range in col Birthday (G) as "Birthdays."

In other sheets, I input student names using this same format: Lastname, Firstname (string value only, no concatenation). What I'd like to do is in these other sheets, have conditional formatting highlight the student name cells meeting the two conditions: cell = StudentInfo!StudentList AND Birthdays = TODAY. I can get conditional formatting for birthday reminders to work easy on the StudentInfo sheet, but am struggling with the conditional formatting logic to highlight student names in other sheets. Something like...
=B4=StudentList AND DATEVALUE(TEXT(Birthdays,"m/d")=TODAY())

Is it possible to use another sheet while conditional formatting in this way? Any help would be very much appreciated. Thanks

答案1

得分: 1

首先,如果您还没有这样做,最好确保您的出生日期使用Excel的内置日期格式(请参阅https://www.youtube.com/watch?v=XEDrzcPo_mc,如果您需要了解这是什么意思)。

接下来,假设在您的非学生信息工作表中,姓名位于列A,以下公式

=MATCH(A5,StudentList,0)

告诉您在范围Studentlist中,名字位于单元格A5的学生的位置。

此学生的出生日期可以使用INDEX函数在范围Birthdays中查找,公式如下

=INDEX(Birthdays,MATCH(A5,StudentList,0))

现在您想知道这个出生日期的日期-月份号码和今天的日期-月份号码是否匹配。

您将需要以下四个函数来进行比较:

TODAY()提供今天的日期

DAY(date)提供给定date的日期-月份号码

MONTH(date)提供给定date的月份号码

AND(v1,v2)提供确定两个布尔值v1v2是否都为TRUE的方法(布尔值是值,要么是TRUE,要么是FALSE)。结果仅在v1v2都为TRUE时为TRUE,否则为FALSE

出生日期的日期-月份号码匹配由以下公式确定

=DAY(INDEX(Birthdays,MATCH(A5,Studentlist,0)))=DAY(TODAY())

如果两个日期-月份号码匹配,则此公式返回TRUE,如果它们不同,则返回FALSE

类似地,出生日期的月份号码与今天的月份号码的匹配由以下公式确定

=MONTH(INDEX(Birthdays,MATCH(A5,StudentList,0)))=MONTH(TODAY())

日期-月份号码和月份号码表达式都是布尔值,可以包装在AND中,以给出以下公式

=AND(DAY(INDEX(Birthdays,MATCH(A5,StudentList,0)))=DAY(TODAY()),MONTH(INDEX(Birthdays,MATCH(A5,StudentList,0)))=MONTH(TODAY()))

如果学生的出生日期在今天发生,则此后者公式返回TRUE,否则返回FALSE

此后者公式是您应该应用于单元格A5的条件格式规则。

注意事项

  1. 此公式应用于非学生信息工作表中包含学生姓名的第一个单元格。我假设这是单元格A5。如果是不同的单元格,请在公式中用适当的单元格值替换两次出现的A5

  2. 使用格式刷复制此第一个单元格的格式到工作表中具有学生姓名的其余单元格。

  3. 最好测试一下非学生信息工作表上的姓名是否与StudentList中的“主”列表匹配。为了在方便的空列中执行此操作,将以下公式放入公式

=MATCH(A5,StudentList,0)

(用适当的单元格引用替代A5),并将此单元格复制到其余名称。任何不匹配都将显示为#N/A错误。您应该将显示此错误的任何姓名与StudentList中的相应姓名进行比较,并进行必要的更正以消除错误。

  1. 如果只是使用“d/m”格式(或者如果这是您的区域设置,则使用“m/d”)将日期输入到Birthdays范围中,Excel可能会将其转换为当前年份的日期。对于确定哪些生日今天发生,这并不重要,因为您只关注日期-月份和月份号码。但是,如果您想要计算学生的年龄,则可能会有所不同。这是需要注意的事项(可能)。
英文:

First, it would be a good idea, if you have not already done so, to make sure your birthdates use Excel's built-in dates (see https://www.youtube.com/watch?v=XEDrzcPo_mc if you need an introduction to what this means).

Next assuming that in your non-StudentInfo worksheets the names are in column A, the formula

=MATCH(A5,StudentList,0)

tells you the position within the range Studentlist of the student whose name is in cell A5.

Further, the birthdate of that student can be looked up in range Birthdays by using this position with the INDEX function. The formula for this is

=INDEX(Birthdays,MATCH(A5,StudentList,0))

You now want to know if the day-within-month number and the month number of this birthdate matches today's day-within-month number and today's month number.

Four functions which you will need for this are:

TODAY() provides today's date

DAY(date) provides the day-within-month number for the given date

MONTH(date) provides the month number for the given date

AND(v1,v2) provides the means of determining whether two boolean values v1 and v2 are both TRUE (a boolean is a value which is either TRUE or FALSE). The result is TRUE if and only if both v1 and v2 are TRUE, otherwise it is FALSE.

The match between the day-within-month numbers of the birthdate and today is determined by the formula

=DAY(INDEX(Birthdays,MATCH(A5,Studentlist,0)))=DAY(TODAY())

and this takes the value TRUE if the two day-within-month numbers match and FALSE if they are different.

Similarly, the match between the month numbers for the birthdate and today is determined by the formula

=MONTH(INDEX(Birthdays,MATCH(A5,StudentList,0)))=MONTH(TODAY())

Both the day-within-month number and month number expressions are booleans and can be wrapped inside an AND to give the formula

=AND(DAY(INDEX(Birthdays,MATCH(A5,StudentList,0)))=DAY(TODAY()),MONTH(INDEX(Birthdays,MATCH(A5,StudentList,0)))=MONTH(TODAY()))

and this is TRUE if the birthday (of the student's birthdate) occurs today and FALSE otherwise.

This latter formula is the one you should apply in the conditional formatting rule for cell A5.

Notes

  1. The formula should be applied to the first cell in each non-StudentInfo worksheet containing a student's name. I have assumed this is cell A5. If it is a different cell then replace the two occurrences of A5 in the formula with with appropriate cell value.

  2. Use the format painter to copy this first cell's format to the remaining cells in the worksheet which have student names.

  3. It would be a good idea to test whether the names on each of the non-StudentInfo worksheets match the "master" list in StudentList. To do this in a convenient empty column put the formula

=MATCH(A5,StudentList,0)

(substituting the appropriate cell reference for A5 and copy this cell down to for the remaining names).

Any mismatches will show up as #N/A errors. You should compare any names showing this error with the corresponding name in StudentList and make any correction necessary to eliminate the error.

  1. If you just enter the dates into range Birthdays using a 'd/m' format (or 'm/d' if that is your locale) Excel will probably convert this to a date in the current year. This does not matter for the purposes of determing which birthdays occur today, since you are only looking at day-within-month and month numbers. However, it might matter if you want to calculate the age in years of the students. Something to be aware of (possibly).

huangapple
  • 本文由 发表于 2023年7月31日 21:15:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76804012.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定