简体   繁体   English

Excel选择性增量

[英]Excel selective increment

Hi I'm trying to write a script in excel that returns a correlating job serial number (which resides on a different sheet) when a cell is filled with the job name. 嗨,我正在尝试在excel中编写一个脚本,该脚本在单元格中填充作业名称时会返回相关的作业序列号(位于不同的工作表上)。

=IF(D5="Misc",Jobs!A2,IF(D5=1715,Jobs!A3,IF(D5=1725,Jobs!A4,IF(D5=5640,Jobs!A5,IF(D5=6121,Jobs!A7,IF(D5=6150,Jobs!A8,IF(D5="6161-IDC",Jobs!A10,IF(D5="6161-JM",Jobs!A11,IF(D5=6161,Jobs!A12,IF(D5=6535,Jobs!A14,IF(D5="Hudson",Jobs!A14,IF(D5="Berendo",Jobs!A15,IF(D5="Berendo-Move",Jobs!A16,IF(D5="Bungalos",Jobs!A17,IF(D5="Bungalo",Jobs!A17,IF(D5="Camarillo",Jobs!A18,IF(D5="Indio",Jobs!A19,IF(D5="Lillian",Jobs!A20,IF(D5="6161-Beam",Jobs!A21,IF(D5="6161-Roof",Jobs!A22))))))))))))))))))))

The above script does what I need it to do, the problem is I need it copied to 30+ rows with ONLY the "D5" value incrementing. 上面的脚本做了我需要做的事情,问题是我只需要将“ D5”值递增即可将其复制到30多个行中。 When I hover in the cell corner and drag down to new cells it increments other references besides the "D5" value. 当我将鼠标悬停在单元格角并向下拖动到新单元格时,除了“ D5”值外,它还会增加其他引用。

I did a search and replace and manually copied the script to each of the 30 cells to get it functional for now but I'm going to have to do that every time I add a job. 我进行了搜索和替换,然后将脚本手动复制到了30个单元中的每个单元中,以使其现在可以正常工作,但是每次添加作业时,我都必须这样做。 I'd like to just add the new job condition and use the fill handle to drag it to all cells, I feel like I need an escape character though to limit what cells are being incremented, I'm just not sure what that would be (it's always going to be column "D", I just need the row incremented to "d6, d7," etc)- thank you in advance for your help! 我只想添加新的工作条件并使用填充手柄将其拖动到所有单元格,我觉得我需要一个转义字符,尽管以限制要递增的单元格,我只是不确定那会是什么(它始终是列“ D”,我只需要将行增加到“ d6,d7”等)-预先感谢您的帮助!

似乎是一个区分大小写更换A$A可能就足够了:

=IF(D5="Misc",Jobs!A$2,IF(D5=1715,Jobs!A$3,IF(D5=1725,Jobs!A$4,IF(D5=5640,Jobs!A$5,IF(D5=6121,Jobs!A$7,IF(D5=6150,Jobs!A$8,IF(D5="6161-IDC",Jobs!A$10,IF(D5="6161-JM",Jobs!A$11,IF(D5=6161,Jobs!A$12,IF(D5=6535,Jobs!A$14,IF(D5="Hudson",Jobs!A$14,IF(D5="Berendo",Jobs!A$15,IF(D5="Berendo-Move",Jobs!A$16,IF(D5="Bungalos",Jobs!A$17,IF(D5="Bungalo",Jobs!A$17,IF(D5="Camarillo",Jobs!A$18,IF(D5="Indio",Jobs!A$19,IF(D5="Lillian",Jobs!A$20,IF(D5="6161-Beam",Jobs!A$21,IF(D5="6161-Roof",Jobs!A$22))))))))))))))))))))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM