Home

Macros and Programming

 

CardboxForumsMacros and Programming > "Needing help with autofill macro.."

Needing help with autofill macro..

Current user: [none]
Register / Log In · Help

Posted By Post

chochato

12-May-2008 04:23

Dear experts,

Desperately needing help. I have sets of numbers with a text description for each set.

Column A Column B
  1 A
  2
  3

  4 B
  5
  6
  7

(and so on..)

Is it possible to do an auto refill to add text A (or B) next to each number by using a macro? The length of numbers varies, and each of this set is separated by a row.

Cheers,
Choc

Charles Welling

12-May-2008 12:45

Choc, I'm not really sure what you meant, but here's a macro that will probably give you a hint. For this macro to work as an autofill, you have to assign it to the ENTER key in the format you are using (Edit, Format, Edit > Tools, Keyboard.) Make sure the macro only works when the ENTER key is pressed when you are editing a record (Context: Editing Records).

So, what happens is this. You enter a number, and you press ENTER to go to the next line. The ENTER key activates the macro, which looks at the number you just typed and compares it with a list of numbers that should have text next to them. If your number matches one of the numbers in the list, the corresponding text will be typed next to the number. If not, the macro will simply type a carriage return.

Try typing one of the numbers in the list (after each "case") and you'll see the text "This is line 1" etc. appear after the number. Type any other number and nothing will happen.
Of course you can change the macro so that it contains your numbers and text.

Command cmdHome
Command cmdEnd+cmdShift
Command cmdCopy
str = trim(ClipboardText)
Select case str
case "123"
str = str & " this is line 1"
case "456"
str = str & " this is line 2"
case "789"
str = str & " this is line 3"
case "0"
str = str & " this is line 4"
End Select
TypeText str & vbCrLf

Quick Reply

Please log in or register before trying to post a reply.

 
© 2010 Cardbox Software Limited   Home