Move value

sevenfive85

New Member
Joined
Jul 21, 2021
Messages
22
Office Version
  1. 365
Platform
  1. Windows
Hi All, I am looking for some codes to move value from one cell to another. In the example from the picture, "D3" has a value so I need to move that value to "A3". I need to check from range D1 to D300. Thank you

1628521356488.png
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Will you have values in the same row in both cols A & D?
If so what should happen?
 
Upvote 0
Will you have values in the same row in both cols A & D?
If so what should happen?
Yes, the numbers will always be in column A & D. I just need it to move from Column D to column A and staying in the same row.
 
Upvote 0
Yes, but will you have (for instance) A3 & D3 with a value?
 
Upvote 0
In that case how about
VBA Code:
Sub sevenfive()
   Dim Rng As Range
   For Each Rng In Range("A:A").SpecialCells(xlBlanks).Areas
      Rng.Value = Rng.Offset(, 3).Value
      Rng.Offset(, 3).Value = ""
   Next Rng
End Sub
 
Upvote 0
In that case how about
VBA Code:
Sub sevenfive()
   Dim Rng As Range
   For Each Rng In Range("A:A").SpecialCells(xlBlanks).Areas
      Rng.Value = Rng.Offset(, 3).Value
      Rng.Offset(, 3).Value = ""
   Next Rng
End Sub
Hi, the code work but because my column A cells have some formula the numbers are not carrying over. Any way to overwrite that? Thank you
 
Upvote 0
That will overwrite your formula with a hard value. Is that what you want?
 
Upvote 0
Ok, how about
VBA Code:
Sub sevenfive()
   Dim Cl As Range
   For Each Cl In Range("A1:A" & Range("D" & Rows.Count).End(xlUp).Row)
      If Cl.Value = "" And Cl.Offset(, 3) <> "" Then
         Cl.Value = Cl.Offset(, 3).Value
         Cl.Offset(, 3).Value = ""
      End If
   Next Cl
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,927
Messages
6,122,309
Members
449,080
Latest member
jmsotelo

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