Conditional copy and past

May 19, 2011 at 17:59:32
Specs: Windows Vista
Hi there

i would like to copy a cell value and paste in the column based on a condition. For example, if the data in one cell contains AA11, I would like to paste only AA. I have several other conditions that I wish to include in the VBA code. Not sure how to go about it. I have already seen various approches by doing quick search but couldnt find anything that meets my requirements. happy to give more detail example if necessary.



See More: Conditional copy and past

May 27, 2011 at 02:02:50
Yes more detail will be needed, you can almost achieve anything in VBA, well within reason of course. What you need to do is be more specific about what you are trying to achieve, also give us an idea of what you are producing so we are on the same page. Then we can help. What you have described above about AA11 to AA is pretty easy. When you say paste, do you mean you want AA to be entered into a cell?

So under the sheets "Sheet Change" method you would do something like

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$A$1" Then
If Target.Value = "AA11" Then
Target.Value = "AA"
End If

End If

End Sub

This checks to see if sheet1, range A1 changes, and if the value in A1 = AA11 then it changes it to AA

This is a very quick example there are better approached, but it works

Report •
Related Solutions

Ask Question