Jump to content

jkfegan

Member
  • Posts

    2
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    United States

About jkfegan

jkfegan's Achievements

0

Reputation

  1. The VLOOKUP function is the best answer. ***FIRST***You'll have to reorder your columns (Swap the data in columns A and B) but then you can get your desired result without the need for a macro. I've attached an Excel file to demostrate how VLOOKUP works with your data. You can see more details in the help files. Notice, that I had to create a named range for a table array. I set a range called RANGE1 equal to A1:B8 (which is the current list of URLs/Telephone numbers). RANGE1 should change to fit your input data size. For more details on naming a range, go to Insert | Name | Define. =VLOOKUP(C2,RANGE1,2,0) In the example above, VLOOKUP will search the first column in RANGE1 (ie COL A) for the search parameter (the data in C2). When it finds a match it will return the value of the data in COL B that corresponds with the row of the match in COL A. This is a *really* great tool for managing data in large spreadsheets. For instance, if you had two telephone numbers (or addresses, or names, IPs, etc) you could set up a bunch of VLOOKUPs to pull out all of that data automatically. Your functions might look something like: =VLOOKUP(F2,RANGE2,2,0) =VLOOKUP(G2,RANGE2,3,0) =VLOOKUP(H2,RANGE2,4,0) =VLOOKUP(I2,RANGE2,5,0) RANGE2 would have to define a larger range (like A1:E8). I did a poor job of explaining it. The best way to find out more is to play around with it and look it up in the help files. I hope this helps... -J Answer_using_VLOOKUP.zip
  2. I'm not sure what kind of options you are looking to add, but the following is a quick example of how to do this. Set up a couple of variables, strDocName and strDirectory. The code below simply sets the strDocName variable to be the current file name. The strDirectory variable is currently set to the Temp directory on your hard drive. This is the place where you can enter in the new directory path you want the file to save to. Notice that the directory variable includes the trailing backslash (this is important). *------------Begin Code Snippit-------------* Dim strDocName as String Dim strDirectory as String strDocName = ActiveDocument.Name strDirectory = "C:\Temp\" ActiveDocument.SaveAs FileName:=strDirectory & strDocName, FileFormat:=wdFormatDocument *------------End Code Snippit --------------* You can look in the VBA Help files for a detailed description of the SaveAs function options (there are a lot). However, you most likely won't need any of them for this instance. The code above simply states that the file should be saved in "C:\Temp\" as a word document (not as RTF, or plain text, HTML, etc.) In case you're new to VBA, the 'strDirectory & strDocName' piece above is a quick way of craming two strings (ie text fields) together. Say your file was named "MyFile.doc". The code above sets the FileName variable in the SaveAs function to "C:\Temp\MyFile.doc". Hope this helps... -J
×
×
  • Create New...