Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Need a simple VBA code to automate a repetitive task.

Hi,

Could you please give a solution for the following:

EXAMPLE

I receive a couple of excel files everyday via email. Every file i open will
have the name of a city

(eg. CA,NY,Boston,NJ) in the cell D9. I have Folders in the C Drive by viz
CA,NY,Boston,NJ. I want to write a VBA code will:

When the excel file is opened on running the macro it will look which city
name is mentioned in the cell D9 and copy the file to the relevant folder.
So if D9 contains NJ the file has to be save in the NJ folder. Right now
this activity is being done manually everyday.

Awaiting a reply.

Thankyou in advance.

Regards,

MADHU


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Need a simple VBA code to automate a repetitive task.

Use this macro in Personal.xls or your own Add-In

Sub test()
Const StoreDir = "C:\T\"
Dim str As String

With ActiveWorkbook
str = .Worksheets(1).Range("D9").Value
.SaveAs StoreDir & str
End With
End Sub

Change C:\T\ to where you want to archive the files.

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"madhu" wrote in message
...
Hi,

Could you please give a solution for the following:

EXAMPLE

I receive a couple of excel files everyday via email. Every file i open
will have the name of a city

(eg. CA,NY,Boston,NJ) in the cell D9. I have Folders in the C Drive by
viz CA,NY,Boston,NJ. I want to write a VBA code will:

When the excel file is opened on running the macro it will look which city
name is mentioned in the cell D9 and copy the file to the relevant folder.
So if D9 contains NJ the file has to be save in the NJ folder. Right now
this activity is being done manually everyday.

Awaiting a reply.

Thankyou in advance.

Regards,

MADHU




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Need a simple VBA code to automate a repetitive task.

If Range("D9") contains the 3 values and you want to get just the last, look
up Split in help, this will split it into an array, and you can use the
UBound(array_name) to get the index of the last item.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Rob van Gelder" wrote in message
...
Use this macro in Personal.xls or your own Add-In

Sub test()
Const StoreDir = "C:\T\"
Dim str As String

With ActiveWorkbook
str = .Worksheets(1).Range("D9").Value
.SaveAs StoreDir & str
End With
End Sub

Change C:\T\ to where you want to archive the files.

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"madhu" wrote in message
...
Hi,

Could you please give a solution for the following:

EXAMPLE

I receive a couple of excel files everyday via email. Every file i open
will have the name of a city

(eg. CA,NY,Boston,NJ) in the cell D9. I have Folders in the C Drive by
viz CA,NY,Boston,NJ. I want to write a VBA code will:

When the excel file is opened on running the macro it will look which

city
name is mentioned in the cell D9 and copy the file to the relevant

folder.
So if D9 contains NJ the file has to be save in the NJ folder. Right now
this activity is being done manually everyday.

Awaiting a reply.

Thankyou in advance.

Regards,

MADHU






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to automate this task [email protected] Excel Discussion (Misc queries) 2 July 14th 06 12:38 AM
can i automate task reminders in excel shootist55 Excel Discussion (Misc queries) 0 May 3rd 05 12:37 AM
Repeat Code Repetitive Actions? chris Excel Discussion (Misc queries) 2 February 18th 05 11:30 PM
Help with very repetitive task in excel...is there an answer? Tim Smith[_2_] Excel Programming 4 July 27th 04 12:48 PM
Repetitive task macro twaccess[_17_] Excel Programming 7 July 22nd 04 08:47 AM


All times are GMT +1. The time now is 09:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"