Sub moveValue()
Dim i As Long
Application.ScreenUpdating = False
For i = 2 To Range("C" & Rows.Count).End(3).Row
If Range("C" & i).Value = "S" Or Range("C" & i).Value = "V" Then Range("H" & i).Cut Range("I" & i)
Next
Application.ScreenUpdating = True
End Sub
Hi Dante,Run this macro on the sheet you want it to work on, that is, if you want it to work on the Sheet1 sheet, select the Sheet1 sheet and run the macro.
VBA Code:Sub moveValue() Dim i As Long Application.ScreenUpdating = False For i = 2 To Range("C" & Rows.Count).End(3).Row If Range("C" & i).Value = "S" Or Range("C" & i).Value = "V" Then Range("H" & i).Cut Range("I" & i) Next Application.ScreenUpdating = True End Sub
???Move Column ("H:H") to Column ("I:I")
Try this:* Removed Values in column "H". I still need the values in the column.
* didn't paste special to Column "I" and changes format.
Sub moveValue()
Dim i As Long
Application.ScreenUpdating = False
For i = 2 To Range("C" & Rows.Count).End(3).Row
If Range("C" & i).Value = "S" Or Range("C" & i).Value = "V" Then Range("I" & i).Value = Range("H" & i).Value
Next
Application.ScreenUpdating = True
End Sub
Hi Dante,???
Try this:
VBA Code:Sub moveValue() Dim i As Long Application.ScreenUpdating = False For i = 2 To Range("C" & Rows.Count).End(3).Row If Range("C" & i).Value = "S" Or Range("C" & i).Value = "V" Then Range("I" & i).Value = Range("H" & i).Value Next Application.ScreenUpdating = True End Sub
Sub moveValue_Mod()
Dim i As Long
Dim NumFmt As String
NumFmt = ""
Application.ScreenUpdating = False
For i = 2 To Range("C" & Rows.Count).End(3).Row
If Range("C" & i).Value = "S" Or Range("C" & i).Value = "V" Then
Range("I" & i).Value = Range("H" & i).Value
If NumFmt = "" Then NumFmt = Range("H" & i).NumberFormat
End If
Next
Range("I2:I" & Range("H" & Rows.Count).End(3).Row).NumberFormat = NumFmt
Application.ScreenUpdating = True
End Sub
I'm not sure where to apply "PasteSpecial xlPasteValuesAndNumberFormats".
Sub moveValue_v1()
Dim i As Long
Application.ScreenUpdating = False
For i = 2 To Range("C" & Rows.Count).End(3).Row
If Range("C" & i).Value = "S" Or Range("C" & i).Value = "V" Then
Range("H" & i).Copy
Range("I" & i).PasteSpecial xlPasteFormulasAndNumberFormats
End If
Next
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
Sub moveValue_v2()
Dim i As Long
Application.ScreenUpdating = False
For i = 2 To Range("C" & Rows.Count).End(3).Row
If Range("C" & i).Value = "S" Or Range("C" & i).Value = "V" Then
Range("H" & i).Copy Range("I" & i)
End If
Next
Application.ScreenUpdating = True
End Sub
Thanks Dante,I show you 2 options:
Option 1:
VBA Code:Sub moveValue_v1() Dim i As Long Application.ScreenUpdating = False For i = 2 To Range("C" & Rows.Count).End(3).Row If Range("C" & i).Value = "S" Or Range("C" & i).Value = "V" Then Range("H" & i).Copy Range("I" & i).PasteSpecial xlPasteFormulasAndNumberFormats End If Next Application.CutCopyMode = False Application.ScreenUpdating = True End Sub
Option 2:
VBA Code:Sub moveValue_v2() Dim i As Long Application.ScreenUpdating = False For i = 2 To Range("C" & Rows.Count).End(3).Row If Range("C" & i).Value = "S" Or Range("C" & i).Value = "V" Then Range("H" & i).Copy Range("I" & i) End If Next Application.ScreenUpdating = True End Sub
![]()
Hi Alex,If you are going to use images you need to include the Row and Column references.
Is there any reason you don't apply the Number Formatting to the whole column or at least each whole section up front ?
Applying number formatting inside the loop on a row by row basis would be the easiest but a bad idea.
Something like this might work. This is mostly using @DanteAmor's solution.
VBA Code:Sub moveValue_Mod() Dim i As Long Dim NumFmt As String NumFmt = "" Application.ScreenUpdating = False For i = 2 To Range("C" & Rows.Count).End(3).Row If Range("C" & i).Value = "S" Or Range("C" & i).Value = "V" Then Range("I" & i).Value = Range("H" & i).Value If NumFmt = "" Then NumFmt = Range("H" & i).NumberFormat End If Next Range("I2:I" & Range("H" & Rows.Count).End(3).Row).NumberFormat = NumFmt Application.ScreenUpdating = True End Sub