Currently using exel 2007. The file format is xlsm. Currently running a macro that returns the previous value of cells in only two columns if the cell is either "0" or blank. When ever I drage the formula from one cell down to another cell I get the value of the cell I dragging from. How I am dragging is putting the mouse in bottom right of cell so pointer turns to plus sign, then I drag. If I right click(copy, paste special, click on formula) it works. I am copying the macro code so this makes this issue more clear. I hope. I need help on being able to drag the formula down and applying the formula not value. Thank you for any help. This is a tough problem for me.
Private oldValArr() As String
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Integer
i = 0
If Target.Column = 38 Or Target.Column = 48 Then
For Each rngCell In Target
If CStr(rngCell.Value) = "0" Or CStr(rngCell.Value) = "" Then
If oldValArr(i) <> "" Then
rngCell.Value = oldValArr(i)
End If
Exit For
End If
i = i + 1
' This If statement to avoid timing issue when users select the whole column
If i > 2000 Then
Exit For
End If
Next
ReDim oldValArr(0)
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error GoTo ErrorHandler
Dim i As Integer
i = 0
If Target.Column = 38 Or Target.Column = 48 Then
ReDim oldValArr(Target.Rows.Count)
If Target.MergeCells = False And Target.Columns.Count = 1 Then
For Each rngCell In Target
If CStr(rngCell.Value) = "Error 2042" Then
rngCell.Value = ""
End If
oldValArr(i) = CStr(rngCell.Value)
i = i + 1
' This If statement to avoid timing issue when users select the whole column
If i > 2000 Then
Exit For
End If
Next
End If
End If
Exit Sub
ErrorHandler:
MsgBox "Please contact Markus Bertel or Shane Tran when seeing exception errors."
End Sub
Private oldValArr() As String
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Integer
i = 0
If Target.Column = 38 Or Target.Column = 48 Then
For Each rngCell In Target
If CStr(rngCell.Value) = "0" Or CStr(rngCell.Value) = "" Then
If oldValArr(i) <> "" Then
rngCell.Value = oldValArr(i)
End If
Exit For
End If
i = i + 1
' This If statement to avoid timing issue when users select the whole column
If i > 2000 Then
Exit For
End If
Next
ReDim oldValArr(0)
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error GoTo ErrorHandler
Dim i As Integer
i = 0
If Target.Column = 38 Or Target.Column = 48 Then
ReDim oldValArr(Target.Rows.Count)
If Target.MergeCells = False And Target.Columns.Count = 1 Then
For Each rngCell In Target
If CStr(rngCell.Value) = "Error 2042" Then
rngCell.Value = ""
End If
oldValArr(i) = CStr(rngCell.Value)
i = i + 1
' This If statement to avoid timing issue when users select the whole column
If i > 2000 Then
Exit For
End If
Next
End If
End If
Exit Sub
ErrorHandler:
MsgBox "Please contact Markus Bertel or Shane Tran when seeing exception errors."
End Sub