VB help! How to copy amounts from one row to another, how to change text?

heathclif

Board Regular
Joined
Jun 12, 2015
Messages
83
Hello all! I am very new to vB and I was hoping you can give me two tips on how to improve my script. Here is my spreadsheet.

Column1Column2Column3Column4Column5Column6Column7Column8Column9Column10Column11Column12Column13Column14Column15Column16Column17Column18Column19
4.03DateItemColorSizePriceOrderReviewNameCredit-4.65ReorderPieceTimeDateReasonShippingCarrierGift
4.03DateItemColorSizePriceOrderReviewNameDebit4.65ReorderPieceTimeDateReasonShippingCarrierGift
546.42DateItemColorSizePriceOrderReviewNameCredit-600ReorderPieceTimeDateReasonShippingCarrierGift
546.42DateItemColorSizePriceOrderReviewNameDebit600ReorderPieceTimeDateReasonShippingCarrierGift
10DateItemColorSizePriceOrderReviewNameCredit-15.32ReorderPieceTimeDateReasonShippingCarrierGift
10DateItemColorSizePriceOrderReviewNameDebit15.32ReorderPieceTimeDateReasonShippingCarrierGift

<colgroup><col style="width:48pt" span="19" width="64"> </colgroup><tbody>
</tbody>

Do you know how to:

1. Copy the dollar amount, contained in the first column 1 to column 11.

2. For each row, if column 10 is originally CREDIT change to DEBIT….if originally DEBIT change to CREDIT.

Also the actual spreadsheet has over 2,000 rows, so the script would have to be able to loop and maintain data integrity. Any jelp would be greatly appreciated! Thank you!:ROFLMAO:




<colgroup><col></colgroup><tbody>
</tbody>
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Also, I see people embed code into the body of the post, how do you do that? Is there a FAQ that has this info?
 
Upvote 0
See if this macro does what you want...
Code:
Sub Test()
  With Range("J1", Cells(Rows.Count, "J").End(xlUp))
    .Offset(, 1).Value = .Offset(, -9).Value
    .Value = Evaluate("IF(" & .Address & "=""Credit"",""Debit"",""Credit"")")
  End With
End Sub

As to your other question, put the word CODE in square brackets before the start of your code and put /CODE in square brackets after the end of your code. Alternately, select all of your code and click the # button in the ribbon at the top of the reply window (it will place the code tags for you automatically).
 
Last edited:
Upvote 0
Hello Rick! Thank you for this. I noticed that you're always helping out other people a lot. Let me try....
 
Upvote 0

Forum statistics

Threads
1,216,071
Messages
6,128,622
Members
449,460
Latest member
jgharbawi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top