Clear “ – “ sign before continue with code

Malcolm torishi

Board Regular
Joined
Apr 26, 2013
Messages
219
Hi can someone help please
I have the following VBA code which is in my worksheet 3 known as “IN” and what this code does is basically cuts and pastes the cell content under column A from my “IN” sheet and pastes it into column C in my “OUT “sheet, but because the “OUT” sheet 4 has a “ - “ sign already under column C what I want the code to do is clear the “ – “ sign first and then continue with the below code. ie paste the cell content under column C in my “OUT” sheet and not have any “-“ signs.
So as this code stands at the minute it pastes the names under “ – “ signs so I can have 3 or 4 “-“ signs and then a name rather than just having names stacked under one another under column C and no “-“ signs.
thanks

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Modified 6/18/2019 3:09 PM EDT
If Target.Column = 4 And Target.Row > 1 Then
Cancel = True
Dim Lastrow As Long
Lastrow = Sheets(4).Cells(Rows.Count, "C").End(xlUp).Row + 1
Target.Offset(, -3).Resize(, 1).Copy Sheets(4).Cells(Lastrow, 3)
Target.Offset(, -3).Resize(, 3).ClearContents
End If
End Sub
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
That's unusual because when you paste data into a cell, it replaces any data that is currently in that cell so the "-" signs should be overwritten. It would be easier to help if you could attach a copy of your file. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data.
 
Upvote 0
I agree with mumps suggestion.

Just based on your description, is this what you're going for?

Code:
Sub Testing    

Columns("C:C").Replace What:="-", Replacement:=""

End Sub
 
Upvote 0
Hello mumps
the problem I have with the above code, as it is written, is because my “OUT” sheet under column C contains the “-“ sign , when I double click on a row on my “IN” sheet it puts the text that’s in column A under the “-“ sign in my OUT sheet rather than deleting it . So what I want the code to do is delete the “-“ sign first from my OUT sheet and then insert the text
 
Upvote 0
I think I understand that, however, the pasted data should overwrite the hyphens. Could you upload a copy of your file to a free site such as www.box.com. or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. Include a detailed explanation of what you would like to do referring to specific cells, rows, columns and worksheets. If the workbook contains confidential information, you could replace it with generic data.
 
Upvote 0
Did you try the code form @Jambi46n2 in post#3?
That should clear the "-" from col C.
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,274
Members
452,628
Latest member
dd2

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