close

Bit of a newbie with Excel I'm afraid, and need some help with this
one.

What I need to do is this (by way of example):

Scan column A in a worksheet and for each cell in that column that
contains quot;Yquot;, move (not copy) the contents of the cell in that row but
in column B to the cell in column C AND then delete the old contents of
the B cell.

ie if An=quot;Yquot; then Cn=Bn AND Bn=quot;quot; where quot;nquot; is any number.

Any ideas on this welcome ! No doubt there's a fairly easy way to do
it.--
morph000
------------------------------------------------------------------------
morph000's Profile: www.excelforum.com/member.php...oamp;userid=30490
View this thread: www.excelforum.com/showthread...hreadid=501434Hi morph000

Try the following code. Press lt;Altgt;lt;F11gt;, select Insert|Module and paste

Option Explicit

Dim iLastRow As Long
Dim iText As Variant
Dim iRow As Long

Sub Testing()
iLastRow = Cells(Rows.Count, quot;Aquot;).End(xlUp).Row
iRow = 1
iText = InputBox(quot;What criteria do you want to usequot;, quot;Enter Criteriaquot;,
vbOKCancel)
For iRow = iRow To iLastRow
If Range(quot;Aquot; amp; iRow).Value = iText Then
With Worksheets(quot;Sheet1quot;)
.Range(quot;Bquot; amp; iRow).Copy
.Range(quot;Cquot; amp; iRow).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
.Range(quot;Bquot; amp; iRow).ClearContents
End With
End If
Next iRow

End Sub

quot;morph000quot; wrote:

gt;
gt; Bit of a newbie with Excel I'm afraid, and need some help with this
gt; one.
gt;
gt; What I need to do is this (by way of example):
gt;
gt; Scan column A in a worksheet and for each cell in that column that
gt; contains quot;Yquot;, move (not copy) the contents of the cell in that row but
gt; in column B to the cell in column C AND then delete the old contents of
gt; the B cell.
gt;
gt; ie if An=quot;Yquot; then Cn=Bn AND Bn=quot;quot; where quot;nquot; is any number.
gt;
gt; Any ideas on this welcome ! No doubt there's a fairly easy way to do
gt; it.
gt;
gt;
gt; --
gt; morph000
gt; ------------------------------------------------------------------------
gt; morph000's Profile: www.excelforum.com/member.php...oamp;userid=30490
gt; View this thread: www.excelforum.com/showthread...hreadid=501434
gt;
gt;


No go I'm afraid. Has multiple compile errors.. --
morph000
------------------------------------------------------------------------
morph000's Profile: www.excelforum.com/member.php...oamp;userid=30490
View this thread: www.excelforum.com/showthread...hreadid=501434Hi morph

Did you copy and paste my code, or did you type it in?

On my side it works perfectly. If you typed it, I suggest you copy my code,
and paste it into your module?

Let me know!

quot;morph000quot; wrote:

gt;
gt; No go I'm afraid. Has multiple compile errors..
gt;
gt;
gt; --
gt; morph000
gt; ------------------------------------------------------------------------
gt; morph000's Profile: www.excelforum.com/member.php...oamp;userid=30490
gt; View this thread: www.excelforum.com/showthread...hreadid=501434
gt;
gt;


Nope. No go, tried 2 P4 3GHz pc's with the same result. Both using Win
XP SP2 and Office XP Pro. Cut and pasted as I normally would. --
morph000
------------------------------------------------------------------------
morph000's Profile: www.excelforum.com/member.php...oamp;userid=30490
View this thread: www.excelforum.com/showthread...hreadid=501434Type of PC doesn't matter, most likely you have line wrapping, for instance

vbOKCancel)

should be on the same line as quot;Enter Criteriaquot;

SkipBlanks _

should be on the same line as xlNone,

--
Regards,

Peo Sjoblom

Portland, Oregon

quot;morph000quot; gt; wrote in
message ...
gt;
gt; Nope. No go, tried 2 P4 3GHz pc's with the same result. Both using Win
gt; XP SP2 and Office XP Pro. Cut and pasted as I normally would.
gt;
gt;
gt; --
gt; morph000
gt; ------------------------------------------------------------------------
gt; morph000's Profile:
gt; www.excelforum.com/member.php...oamp;userid=30490
gt; View this thread: www.excelforum.com/showthread...hreadid=501434
gt;

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()