View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default multi-function macro possibilities?

Dim v as Variant, res as Variant
Dim i as long, rng as Range, cell as Range

v = Array("Header2","Header7","Header9")
for i = lbound(v) to ubound(v)
set rng = Rows(1).Cells
res = Application.Match(v(i),rng,0)
if not iserror(res) then
columns(res).Delete
end if
Next
res = Application.MAtch("Header3"),Rows(1),0)
if not iserror(res) then
set rng = Range(cells(2,res),Cells(rows.count,res).End(xlup) )
for each cell in res
cell.Value = Left(cell,Len(cell)-3)
Next
End if


If the end is always "-01" then turn on the macro recorder, select the
column, and do Edit=Replace
What: -01
With: <leave blank

then turn off the macro recorder and adapt the recorded code to your base
code.

--
Regards,
Tom Ogilvy



"andysgirl8800" wrote:


Hi all!
I'm new to this forum, but somewhat familiar with VBA in MSAccess97.
What I am hoping to accomplish is to create a macro, to be run with a
button click that will perform the following functions:

1) Delete some unecessary columns from one spreadsheet that will always
have the same column headers in the same format, but updated every day
2) Delete specific data from one column, i.e., fields contain a number
like 415444459-01, I want to delete the -01 part and leave the rest of
the number
3) Export the newly formated data, minus header row, into an existing
table in MSAccess97 (which I may have to do via append query within
Access)

I'm really hoping for some suggestions and/or direction on how to begin
coding this macro. I've been browsing this forum for a few hours now,
and looking through some code, but can't seem to figure out how to
program correctly to do the things I need. Any help would be
tremendously appreciated!

Thanks


--
andysgirl8800
------------------------------------------------------------------------
andysgirl8800's Profile: http://www.excelforum.com/member.php...o&userid=34752
View this thread: http://www.excelforum.com/showthread...hreadid=545141