【问题标题】:Copying strings over floats in 'Do While' loop在“Do While”循环中将字符串复制到浮点数上
【发布时间】:2014-02-20 15:09:18
【问题描述】:

我正在尝试创建一个宏,该宏将字符串复制到接下来的几个单元格中的浮点数/整数上,直到它碰到另一个字符串。我发现了一些我认为可以工作的代码,并希望帮助修改它(或者如果我应该采取不同的方向,请告诉我):

Sub ReplaceNumberswithText()
' Performs Do loop, testing at top of loop.
' Loops until empty cell is reached.
' Note that you can also use a Do While Not IsEmpty(ActiveCell) loop.



  ' Test contents of active cell; if active cell is empty, exit loop.
Do Until IsEmpty(ActiveCell)

  If ActiveCell.Text Then Text.Copy
  End If
     ' Copies cell contents.


     ' Step down 1 row to the next cell.
     ActiveCell.Offset(1, 0).Select

     Selection.Paste

    Else: If ActiveCell.Value = 0 Then ActiveCell.Offset(1, 0).Select
     End If


    ' Return to top of loop.
    Loop
End Sub

我需要将每个字符串复制到以下浮点数/整数上,直到下一个字符串。然后重复直到列的末尾(A 列)。

http://www.flickr.com/photos/hillsindustries/12198631954/

【问题讨论】:

  • 那太好了。我绝对愿意接受建议......这张表大约有 11,000 行,所以我会说复制粘贴需要几天的艰苦劳动......

标签: string vba excel loops


【解决方案1】:

选择范围、主页 > 编辑 > 查找和选择、转到特殊...、常量、数字(仅限)、确定、Del=、Up、Ctrl+回车

【讨论】:

  • 这将让我以几种不同的方式查看我们的库存和利润。关于能够切片和切块此信息的好技巧。谢谢,谢谢,谢谢!
  • 完美解决方案。如果我有更多的代表,我会投票!
  • + 1 对于非 VBA 解决方案。 @user3246871:If I had more rep, I would vote up!我为你做的:)
  • 不,请不要那样做 :)
  • 再次感谢您。我们的库存系统在许多重要报告上都采用了相同类型的格式。我已多次使用此解决方案,节省了大量个人时间。谢谢。
猜你喜欢
  • 2015-05-21
  • 1970-01-01
  • 1970-01-01
  • 2021-01-31
  • 2019-10-31
  • 1970-01-01
  • 1970-01-01
  • 2022-01-23
  • 2014-04-26
相关资源
最近更新 更多