简体   繁体   English

Excel自动填充列X +++ .. Y ++ .. Z +

[英]Excel auto fill column by X+++..Y++..Z+

EXL

How do I autofill the values in between? 如何在两者之间自动填充值?

Select Column A, CTRL+G -> Blanks -> OK Type = press UpArrow , then press CTRL+ENTER 选择A列, CTRL+G - > Blanks - > OK类型=UpArrow ,然后按CTRL+ENTER

See this link for explanation. 请参阅此链接以获取解释。 It is basically find all blanks and enter a formula to all of them. 它基本上找到所有空白并输入所有这些空白的公式。

EDIT: as @kurast pointed out for safety/sanity reasons select all and Copy and Paste Special as Values. 编辑:因为@kurast指出出于安全/理智的原因选择全部并复制和粘贴特殊值作为值。

I've not found a great way to do this, ever. 我永远找不到一个好方法。 There's a not-great workaround I use from time to time: 我经常使用一个不太好的解决方法:

  1. Insert a column after A A之后插入一列
  2. Copy the first value over - so B1: =A1 复制第一个值 - 所以B1: =A1
  3. Starting at B2, drag the formula of B2: =IF(A2 = "", B1, A2) 从B2开始,拖动公式B2: =IF(A2 = "", B1, A2)
  4. Copy B:B 复制B:B
  5. Paste values into A:A 将值粘贴到A:A
  6. Delete column B 删除B

Make another column to generate them for you. 创建另一列以便为您生成它们。 Insert a new column B, make B1 = A1 , then use this formula in B2 : 插入一个新列B,使B1 = A1 ,然后在B2使用此公式:

=IF(A2="",B1+1,A2)

And drag it down; 把它拖下来; it will perform the logic you want. 它会执行你想要的逻辑。

Then you can copy column B, and paste special values -> values to "hard-code" the results. 然后,您可以复制B列,并paste special values - > values以“硬编码”结果。


Edit: I am not sure exactly what you mean by "auto-fill"; 编辑:我不确定你的意思是“自动填充”; @corsiKa's formula will result in @ corsiKa的公式将导致

11122222333444...

Mine will result in: 我的结果将是:

12323456345456...

to end up with 结束

simulate2

use this VBA 使用这个VBA

Sub FillValues()
    Dim c As Range
    For Each c In Range("A1:A" & Range("B" & Rows.Count).End(xlUp).Row)
        If IsEmpty(c) Then c = c.Offset(-1, 0)
    Next c
End Sub

hit ALT + F11 to open VBE, then right click in the Project Explorer ( CTRL + R ) 点击ALT + F11打开VBE,然后右键单击Project ExplorerCTRL + R

and Insert » Module Insert » Module

then ALT + F8 to View Macros » select FillValues 然后ALT + F8 View Macros »选择FillValues

to get 要得到

自动填充模拟

use 采用

Sub FillValues()
    Dim c As Range
    For Each c In Range("A1:A" & Range("B" & Rows.Count).End(xlUp).Row)
        If IsEmpty(c) Then c = c.Offset(-1, 0) +1
    Next c
End Sub

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

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