Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Macro: Altering cells in a range

I need to alter approximately 10,000 cells on a single sheet.
The range I need to replace is G2 through the end of the column, which
varies depending on call flow.

The cell is imported in one of the following two patterns:
9/27/2008 2:09:18 AM
10/27/2008 12:09:18 AM

I need the output of the cell to only be the date: 9/27/2008 or 10/27/2008

If anyone can shed any light on this for me, I would greatly appreciate it.

--Ian
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Macro: Altering cells in a range

here's one way:

Sub test()
Dim ws As Worksheet
Dim lastrow As Long
Dim i As Long

Set ws = Worksheets("Sheet1")
lastrow = ws.Cells(Rows.Count, "G").End(xlUp).Row
Application.ScreenUpdating = False

With ws
For i = 2 To lastrow
.Range("G" & i).Value = Split(Range("A1"))(0)
Next
End With
Application.ScreenUpdating = True
End Sub

--


Gary

"Mahnian" wrote in message
...
I need to alter approximately 10,000 cells on a single sheet.
The range I need to replace is G2 through the end of the column, which
varies depending on call flow.

The cell is imported in one of the following two patterns:
9/27/2008 2:09:18 AM
10/27/2008 12:09:18 AM

I need the output of the cell to only be the date: 9/27/2008 or 10/27/2008

If anyone can shed any light on this for me, I would greatly appreciate
it.

--Ian



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Macro: Altering cells in a range

Does it have to be a macro? If not, select the entire column, click
Data/TextToColumns on the menu bar, select Delimited on the first panel and
click Next, check the Space checkbox and click Next, click the first column
in chart and pick Date-MDY in the option button group, click the other two
columns (one at a time) and select Do Not Import (Skip) from the option
button group, then click the Finish button.

--
Rick (MVP - Excel)


"Mahnian" wrote in message
...
I need to alter approximately 10,000 cells on a single sheet.
The range I need to replace is G2 through the end of the column, which
varies depending on call flow.

The cell is imported in one of the following two patterns:
9/27/2008 2:09:18 AM
10/27/2008 12:09:18 AM

I need the output of the cell to only be the date: 9/27/2008 or 10/27/2008

If anyone can shed any light on this for me, I would greatly appreciate
it.

--Ian


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Macro: Altering cells in a range

Unfortunately, this did not work. I am not sure what it did but nothing
changed on the sheet.

"Gary Keramidas" wrote:

here's one way:

Sub test()
Dim ws As Worksheet
Dim lastrow As Long
Dim i As Long

Set ws = Worksheets("Sheet1")
lastrow = ws.Cells(Rows.Count, "G").End(xlUp).Row
Application.ScreenUpdating = False

With ws
For i = 2 To lastrow
.Range("G" & i).Value = Split(Range("A1"))(0)
Next
End With
Application.ScreenUpdating = True
End Sub

--


Gary

"Mahnian" wrote in message
...
I need to alter approximately 10,000 cells on a single sheet.
The range I need to replace is G2 through the end of the column, which
varies depending on call flow.

The cell is imported in one of the following two patterns:
9/27/2008 2:09:18 AM
10/27/2008 12:09:18 AM

I need the output of the cell to only be the date: 9/27/2008 or 10/27/2008

If anyone can shed any light on this for me, I would greatly appreciate
it.

--Ian




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Macro: Altering cells in a range

did you change the sheet name to match yours?

is the data in column G a date or a string? you didn't give a lot of
information to work with.

--


Gary

"Mahnian" wrote in message
...
Unfortunately, this did not work. I am not sure what it did but nothing
changed on the sheet.

"Gary Keramidas" wrote:

here's one way:

Sub test()
Dim ws As Worksheet
Dim lastrow As Long
Dim i As Long

Set ws = Worksheets("Sheet1")
lastrow = ws.Cells(Rows.Count, "G").End(xlUp).Row
Application.ScreenUpdating = False

With ws
For i = 2 To lastrow
.Range("G" & i).Value = Split(Range("A1"))(0)
Next
End With
Application.ScreenUpdating = True
End Sub

--


Gary

"Mahnian" wrote in message
...
I need to alter approximately 10,000 cells on a single sheet.
The range I need to replace is G2 through the end of the column, which
varies depending on call flow.

The cell is imported in one of the following two patterns:
9/27/2008 2:09:18 AM
10/27/2008 12:09:18 AM

I need the output of the cell to only be the date: 9/27/2008 or
10/27/2008

If anyone can shed any light on this for me, I would greatly appreciate
it.

--Ian








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Macro: Altering cells in a range

By the way, if your entries are already real dates and if there are no
calculations being performed on that column's data where the time would
affect the calculation, then you can simply select the column and format it
as a Date using the first item in the list... the time will still be there,
but you won't see it.

Also, if you need to do this inside of a macro, this code line should do the
same thing in code as the procedure I originally posted...

Columns(1).TextToColumns ConsecutiveDelimiter:=True, Space:=True, _
DataType:=xlDelimited, FieldInfo:= _
Array(Array(1, 3), Array(2, 9), Array(3, 9))

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
Does it have to be a macro? If not, select the entire column, click
Data/TextToColumns on the menu bar, select Delimited on the first panel
and click Next, check the Space checkbox and click Next, click the first
column in chart and pick Date-MDY in the option button group, click the
other two columns (one at a time) and select Do Not Import (Skip) from the
option button group, then click the Finish button.

--
Rick (MVP - Excel)


"Mahnian" wrote in message
...
I need to alter approximately 10,000 cells on a single sheet.
The range I need to replace is G2 through the end of the column, which
varies depending on call flow.

The cell is imported in one of the following two patterns:
9/27/2008 2:09:18 AM
10/27/2008 12:09:18 AM

I need the output of the cell to only be the date: 9/27/2008 or
10/27/2008

If anyone can shed any light on this for me, I would greatly appreciate
it.

--Ian



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Macro: Altering cells in a range

that's what i was trying to get at in my follow-up.

--


Gary

"Rick Rothstein" wrote in message
...
By the way, if your entries are already real dates and if there are no
calculations being performed on that column's data where the time would
affect the calculation, then you can simply select the column and format
it as a Date using the first item in the list... the time will still be
there, but you won't see it.

Also, if you need to do this inside of a macro, this code line should do
the same thing in code as the procedure I originally posted...

Columns(1).TextToColumns ConsecutiveDelimiter:=True, Space:=True, _
DataType:=xlDelimited, FieldInfo:= _
Array(Array(1, 3), Array(2, 9), Array(3, 9))

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
Does it have to be a macro? If not, select the entire column, click
Data/TextToColumns on the menu bar, select Delimited on the first panel
and click Next, check the Space checkbox and click Next, click the first
column in chart and pick Date-MDY in the option button group, click the
other two columns (one at a time) and select Do Not Import (Skip) from
the option button group, then click the Finish button.

--
Rick (MVP - Excel)


"Mahnian" wrote in message
...
I need to alter approximately 10,000 cells on a single sheet.
The range I need to replace is G2 through the end of the column, which
varies depending on call flow.

The cell is imported in one of the following two patterns:
9/27/2008 2:09:18 AM
10/27/2008 12:09:18 AM

I need the output of the cell to only be the date: 9/27/2008 or
10/27/2008

If anyone can shed any light on this for me, I would greatly appreciate
it.

--Ian





  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Macro: Altering cells in a range

rick:
have a question:

noticed something when i've recorded a macro using texttocolumns. if i just
selected fixed width , click finish then save it, and i then record another,
but go through the wizard and select text under column data format, the
code looks the same.

am i missing something?

--


Gary

"Rick Rothstein" wrote in message
...
By the way, if your entries are already real dates and if there are no
calculations being performed on that column's data where the time would
affect the calculation, then you can simply select the column and format
it as a Date using the first item in the list... the time will still be
there, but you won't see it.

Also, if you need to do this inside of a macro, this code line should do
the same thing in code as the procedure I originally posted...

Columns(1).TextToColumns ConsecutiveDelimiter:=True, Space:=True, _
DataType:=xlDelimited, FieldInfo:= _
Array(Array(1, 3), Array(2, 9), Array(3, 9))

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
Does it have to be a macro? If not, select the entire column, click
Data/TextToColumns on the menu bar, select Delimited on the first panel
and click Next, check the Space checkbox and click Next, click the first
column in chart and pick Date-MDY in the option button group, click the
other two columns (one at a time) and select Do Not Import (Skip) from
the option button group, then click the Finish button.

--
Rick (MVP - Excel)


"Mahnian" wrote in message
...
I need to alter approximately 10,000 cells on a single sheet.
The range I need to replace is G2 through the end of the column, which
varies depending on call flow.

The cell is imported in one of the following two patterns:
9/27/2008 2:09:18 AM
10/27/2008 12:09:18 AM

I need the output of the cell to only be the date: 9/27/2008 or
10/27/2008

If anyone can shed any light on this for me, I would greatly appreciate
it.

--Ian





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
Altering the range that is plotted by a chart via VBA Peter Rooney Charts and Charting in Excel 4 October 21st 05 10:59 AM
pivot tables reports - altering display of (blank) cells cak Excel Worksheet Functions 1 August 22nd 05 12:39 AM
Altering read/write facility of individual cells Nick Read Excel Discussion (Misc queries) 5 January 29th 05 12:06 AM
Help with altering a SaveAs macro . . . WillRn Excel Programming 2 November 3rd 04 02:03 PM
Help with altering a download macro bob Excel Programming 0 November 2nd 04 10:06 PM


All times are GMT +1. The time now is 11:46 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"