PDA

View Full Version : [SOLVED] Please Help. trying to check for specific text in cell value :S



plasteredric
09-11-2017, 02:15 PM
Hi All, been searching the internet for hours trying to find an answer to this.

I'm using a control button to start a macro that copies data from one sheet to another.

That part works fine, but I need it to check that a cell contains the text value "True" before continuing with the copy process, or to show a message box with a warning if the value is anything but "True".
The cell I want to evaluate is J2 on sheet called "Import" and the control button is on a different sheet.

The Code i have so far is



Sub GET_CLEAN_DATA()
' GET_CLEAN_DATA Macro
Dim sStartSheet As String
sStartSheet = ActiveSheet.Name




Application.Goto Reference:="CLEAN_DATARANGE"
Selection.Copy
Worksheets(sStartSheet).Select
Range("AI17").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A1").Select

End Sub

SamT
09-11-2017, 02:47 PM
If UCase(Sheets("IMPORT).Range("J2")) = "TRUE" then
Selection.Copy
Else
MsgBox "Danger, Will Robinson!"
Exit Sub
End If

Sheets(sStartSheet).Range("AI17").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

Range("A1").Select

plasteredric
09-12-2017, 02:43 PM
Thanks very much, worked a treat.