Mindy79 Posted April 4, 2012 Report Share Posted April 4, 2012 How do you stop macro at blank cell from excel! Ex: 1234 5678 (empty) I want my macro to stop when it can not see data or blank cell! I use copy paste from excel to notepad and i want macro to stop when it see nothing or empty data copy from excel Quote Link to comment Share on other sites More sharing options...
Cory Posted April 4, 2012 Report Share Posted April 4, 2012 I assume you mean the selection range could be larger than the actual propagated range in Excel. If this is the case I would create variables for the carriage return and line feed non-printing characters and suck the clip into a variable and find the position of CRLFCRLF (Back to back CRLF) and copy everything before that to the same variable and paste that. Variable Set to ASCII Char 9 to %Tab% Variable Set to ASCII Char 10 to %LF% Variable Set to ASCII Char 13 to %CR% Variable Set String %Clip% from the clipboard contents Variable Set Integer %Position% to the position of "%CR%%LF%%CR%%LF%" in %Clip% Variable Modify Integer %Position%: Decrement Variable Modify String: Copy a substring in %Clip%, starting at 1 and %Position% characters long to %Clip% Variable Modify String: Save %Clip% to the clipboard <VARIABLE SET TO ASCII CHAR Value="9" Destination="%Tab%"/> <VARIABLE SET TO ASCII CHAR Value="10" Destination="%LF%"/> <VARIABLE SET TO ASCII CHAR Value="13" Destination="%CR%"/> <VARIABLE SET STRING Option="\x02" Destination="%Clip%" NoEmbeddedVars="FALSE"/> <VARIABLE SET INTEGER Option="\x0E" Destination="%Position%" Text_Variable="%Clip%" Text="%CR%%LF%%CR%%LF%" Ignore_Case="FALSE"/> <VARIABLE MODIFY INTEGER Option="\x08" Destination="%Position%"/> <VARIABLE MODIFY STRING Option="\x09" Destination="%Clip%" Variable="%Clip%" Start="1" Count="%Position%" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x10" Destination="%Clip%" NoEmbeddedVars="FALSE"/> Quote Link to comment Share on other sites More sharing options...
Mindy79 Posted April 4, 2012 Author Report Share Posted April 4, 2012 Thanks for the help but what i need something simple copy paste. Ex: Excel. Notepad Copy. 123. Paste. 123 Stop macro because blank in excel Quote Link to comment Share on other sites More sharing options...
Cory Posted April 4, 2012 Report Share Posted April 4, 2012 So you are copying one at a time? If so you can do something similar. First off you need to realize that in many apps if you execute a copy command and there's nothing to copy it does not replace what's on the clipboard so clear your clipboard to be safe. But in Excel an empty cell copy converted to text is nothing but a EoL (End of Line) which is made up of two non-printing characters Carriage Return 0x0d and Line Feed 0x0a. What you could do it like in my previous example set a variable to the contents of the clipboard and if it equals EoL then abort. Alternatively you can trim (removes all leading and trailing non-printing characters) the variable and if the variable is empty then abort. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.