Copy and paste values in different cells

ychin130

New Member
Joined
Aug 10, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi,

I'm trying to copy the A1 value to the A2 cell and clear the content of A1, and copy the B1 value and paste it A3, the # rows may increase and I can have more rows. I havent been able to get to the expected result.

Any help is appreciated?


AB
Total Federal Work Opportunity Tax Credits Earned to Date: $100,000.00Less: Credits Previously Invoiced: $75,000.00
Total Federal Work Opportunity Tax Credits Earned to Date: $100,000.00Less: Credits Previously Invoiced: $85,000.00

Expected result

AB
Less: Credits Previously Invoiced: $75,000.00
Total Federal Work Opportunity Tax Credits Earned to Date: $100,000.00
Less: Credits Previously Invoiced: $75,000.00
Less: Credits Previously Invoiced: $85,000.00
Total Federal Work Opportunity Tax Credits Earned to Date: $100,000.00
Less: Credits Previously Invoiced: $85,000.00
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
try this code, it is very fast because it uses variant arrays.
VBA Code:
Sub test()
Dim outarr()
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
inarr = Range(Cells(1, 1), Cells(lastrow, 2))
ReDim outarr(1 To 2 + lastrow * 3, 1 To 2)
indi = 2
For i = 1 To lastrow - 1
  outarr(indi, 2) = inarr(i, 2) ' copy B2 to B2
  indi = indi + 1
  outarr(indi, 1) = inarr(i, 1)  ' copy A1 to A2
  indi = indi + 1
  outarr(indi, 1) = inarr(i, 2) ' copy B2 to A3
  indi = indi + 1
Next i
 Range(Cells(1, 1), Cells(2 + lastrow * 3, 2)) = outarr
 
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,073
Messages
6,128,645
Members
449,461
Latest member
kokoanutt

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