Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

vba - Copying strings over floats in 'Do While' loop

I'm attempting to create a macro that copies a string over a float/integer in the next few cells until it hits another string. I've found some code that I thought would work and would like help modifying it (or if I should go in a different direction, tell me):

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

I need to copy each string over the following floats/integers, until the next string. Then repeat until the end of the column (column A).

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Select range, Home > Editing > Find & Select, Go To Special…, Constants, Numbers (only), OK, Del, =,Up, Ctrl+Enter.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...