PC Review


Reply
Thread Tools Rate Thread

Automatically Accept Replace Values in Text-to-Columns macro

 
 
sbitaxi@gmail.com
Guest
Posts: n/a
 
      30th Jul 2008
Hello:

Working on a macro to format a report and strip out unnecessary dates,
but in order to do that I need to separate the time from the date. I
first insert a column after the column containing the date field
(DateFld, there are a few of them), then TextToColumns delimited by
"T" for time, and format the date field to a date format.

Every time it gets to the .TextToColumns step, it asks if I want to
replace the data and I want it to automatically do it without prompt.

I know this code could be cleaner, but I'm pretty green at this. Here
it is!

For Each Thing In DateFld
Columns(Thing + 1).Insert Shift:=xlRight
Columns(Thing).Select

With Selection.Columns
.TextToColumns Destination:=Columns(Thing), Other:=True,
OtherChar:="T"
.NumberFormat = "m/d/yyyy"
End With

Rng.AutoFilter Field:=Thing, Criteria1:="<" & RptDate
Range("3:" & Last).SpecialCells(xlCellTypeVisible)
(1).EntireRow.Delete
WS.AutoFilterMode = False
Rng.AutoFilter Field:=Thing, Criteria1:=">=" & EndRptDate
Range("3:" & Last).SpecialCells(xlCellTypeVisible)
(1).EntireRow.Delete
WS.AutoFilterMode = False
Next

Thank you!

Steven
 
Reply With Quote
 
 
 
 
Barb Reinhardt
Guest
Posts: n/a
 
      31st Jul 2008
Have you tried

Application.DisplayAlerts = FALSE
and
Application.Displayalerts = TRUE

before and after the Text To Columns?
--
HTH,
Barb Reinhardt



"(E-Mail Removed)" wrote:

> Hello:
>
> Working on a macro to format a report and strip out unnecessary dates,
> but in order to do that I need to separate the time from the date. I
> first insert a column after the column containing the date field
> (DateFld, there are a few of them), then TextToColumns delimited by
> "T" for time, and format the date field to a date format.
>
> Every time it gets to the .TextToColumns step, it asks if I want to
> replace the data and I want it to automatically do it without prompt.
>
> I know this code could be cleaner, but I'm pretty green at this. Here
> it is!
>
> For Each Thing In DateFld
> Columns(Thing + 1).Insert Shift:=xlRight
> Columns(Thing).Select
>
> With Selection.Columns
> .TextToColumns Destination:=Columns(Thing), Other:=True,
> OtherChar:="T"
> .NumberFormat = "m/d/yyyy"
> End With
>
> Rng.AutoFilter Field:=Thing, Criteria1:="<" & RptDate
> Range("3:" & Last).SpecialCells(xlCellTypeVisible)
> (1).EntireRow.Delete
> WS.AutoFilterMode = False
> Rng.AutoFilter Field:=Thing, Criteria1:=">=" & EndRptDate
> Range("3:" & Last).SpecialCells(xlCellTypeVisible)
> (1).EntireRow.Delete
> WS.AutoFilterMode = False
> Next
>
> Thank you!
>
> Steven
>

 
Reply With Quote
 
sbitaxi@gmail.com
Guest
Posts: n/a
 
      31st Jul 2008
Thank you Barb, that did it.


Steven

On Jul 30, 7:25*pm, Barb Reinhardt
<BarbReinha...@discussions.microsoft.com> wrote:
> Have you tried
>
> Application.DisplayAlerts = FALSE
> and
> Application.Displayalerts = TRUE
>
> before and after the Text To Columns?
> --
> HTH,
> Barb Reinhardt
>
> "sbit...@gmail.com" wrote:
> > Hello:

>
> > Working on a macro to format a report and strip out unnecessary dates,
> > but in order to do that I need to separate the time from the date. I
> > first insert a column after the column containing the date field
> > (DateFld, there are a few of them), then TextToColumns delimited by
> > "T" for time, and format the date field to a date format.

>
> > Every time it gets to the .TextToColumns step, it asks if I want to
> > replace the data and I want it to automatically do it without prompt.

>
> > I know this code could be cleaner, but I'm pretty green at this. Here
> > it is!

>
> > For Each Thing In DateFld
> > * * Columns(Thing + 1).Insert Shift:=xlRight
> > * * Columns(Thing).Select

>
> > * * With Selection.Columns
> > * * * * .TextToColumns Destination:=Columns(Thing), Other:=True,
> > OtherChar:="T"
> > * * * * .NumberFormat = "m/d/yyyy"
> > * * End With

>
> > * * Rng.AutoFilter Field:=Thing, Criteria1:="<" & RptDate
> > * * Range("3:" & Last).SpecialCells(xlCellTypeVisible)
> > (1).EntireRow.Delete
> > * * WS.AutoFilterMode = False
> > * * Rng.AutoFilter Field:=Thing, Criteria1:=">=" & EndRptDate
> > * * Range("3:" & Last).SpecialCells(xlCellTypeVisible)
> > (1).EntireRow.Delete
> > * * WS.AutoFilterMode = False
> > Next

>
> > Thank you!

>
> > Steven


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
A macro solution - replace text given the values Sinner Microsoft Excel Programming 8 17th Sep 2008 04:29 PM
How do I automatically accept a solver solution in a macro? =?Utf-8?B?Y2xt?= Microsoft Excel Programming 1 18th Jan 2006 05:09 PM
Hi, can I replace plain text with bold text using Find/Replace or possibly with a macro? Derek Microsoft Excel New Users 9 4th Mar 2004 11:39 AM
If values in two columns are equal I want to automatically execute a macro Tom Rinks Microsoft Excel Programming 1 1st Feb 2004 04:58 PM
Getting a list of columns that accept null values Natrajk Microsoft ADO .NET 5 14th Jul 2003 01:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:00 AM.