基于同一行第一列中的任何文本对列进行条件格式设置

发布于 2024-12-06 04:37:23 字数 257 浏览 0 评论 0原文

我不确定这是否可以在不使用 VB 的情况下实现,但我试图通过条件格式来做到这一点。基本上,如果在该行中输入了记录,我有一列(K 列)将始终具有相同的值(345)。基本上,当我填充报告时,如果该行中有任何数据,我只想将值 (345) 输入到 K 列中。我试图仅使用 A 列作为参考。我搞乱了 =IF(ISTEXT(Col.A location),"345","") 但这毫无进展。所以,我正在寻找 vba 之外的想法,但如果没有可能性,那么我认为 vba 是可行的方法。 :)

I'm not sure if this is even possible without going to VB, but I was trying to do it through conditional formatting. Basically I have a column (Column K) that will always be the same value (345) if there is a record entered in that row. Basically when I populate my reports I simply want the value (345) to be entered into Column K if there is any data in that row. I was trying to just use Column A as a reference. I was messing with =IF(ISTEXT(Col.A location),"345","") but that's getting nowhere. So, I'm looking for ideas outside of vba, but if there are no possibilities then vba is the way to go I suppose. :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

一紙繁鸢 2024-12-13 04:37:23

假设您的数据位于 A 至 J 列中,并且从第 2 行开始,请在 K2 中输入此数据并根据需要向下复制:

=IF(COUNTA(A2:J2),345,"")

编辑:对于条件格式公式,您不需要“If”部分,因为格式是已经...条件:

=COUNTA(A2:J2)

Assuming your data is in columns A to J, and that it starts in row 2, enter this in K2 and copy down as necessary:

=IF(COUNTA(A2:J2),345,"")

Edit: For a conditional formatting formula you don't need the "If" part, because the formatting is already ... conditional:

=COUNTA(A2:J2)

马蹄踏│碎落叶 2024-12-13 04:37:23

这行得通吗?

=IF(ISBLANK(A1),"","345")

Will this work?

=IF(ISBLANK(A1),"","345")

塔塔猫 2024-12-13 04:37:23

此代码用于判断 A 列中是否有 COUNTA(INDIRECT("$A$"&ROW()))>0,但我认为您不能使用条件设置单元格的值格式化。但是,使用条件格式时,您必须提前知道数据将向下移动多远,除非您只是将其放入所有行中。

为什么不在复制时将其放入 VBA 代码中,您可以找出最后一行是什么,然后将 IF() 公式放入。您可以使用以下代码:

Dim r1 As Range
Set r1 = Range("K1")
r1.NumberFormat = "General"
r1 = "=IF(COUNTA(INDIRECT(""$A$""&ROW())>0,""345"","""")"
r1.AutoFill Destination:=Range(r1, r1.Offset(200))

This code works to tell whether column A has something in it or not COUNTA(INDIRECT("$A$"&ROW()))>0, but I don't think you can set the value of the cell using conditional formatting. But with conditional formatting you have to know ahead of time how far down your data is going to go unless you just put it in all the rows.

Why don't you just put it in your VBA code when you are copying, you can find out what the last row is then put the IF() formula in. You can use this code:

Dim r1 As Range
Set r1 = Range("K1")
r1.NumberFormat = "General"
r1 = "=IF(COUNTA(INDIRECT(""$A$""&ROW())>0,""345"","""")"
r1.AutoFill Destination:=Range(r1, r1.Offset(200))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文