Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Delete columns based on a cell reference date value

I have a sheet titled 'data' that has source information and row 1 has
columns H to BG with dates.

On sheet 'Control' is a cell that has a free format cell for dates to be
entered. I have named this cell 'WCDATA' for ease of another piece of code.

I am tring to create a macro that will locate the date specified in WCDATA
on the data sheet and delete all columns from H until that which matches
WCDATA.

Fortunately I have been running on a test file and I have tried several
options but after considerable hair pulling am seeking assistance as am
getting close to deadline now.

Any assistance appreciated.

R
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 896
Default Delete columns based on a cell reference date value

Sub cus()
Dim cell As Range
For i = Range("H1").Column To Worksheets("data").Range
("H1:BG1").Cells.Count
If Cells(1, i).Value < Range("WCDATA").Value Then
Cells(1, i).Columns.EntireColumn.Delete
i = i - 1
Else
Exit For
End If
Next i

End Sub


On 18 Lis, 08:59, fishy wrote:
I have a sheet titled 'data' that has source information and row 1 has
columns H to BG with dates.

On sheet 'Control' is a cell that has a free format cell for dates to be
entered. I have named this cell 'WCDATA' for ease of another piece of code.

I am tring to create a macro that will locate the date specified in WCDATA
on the data sheet and delete all columns from H until that which matches
WCDATA.

Fortunately I have been running on a test file and I have tried several
options but after considerable hair pulling am seeking assistance as am
getting close to deadline now.

Any assistance appreciated.

R


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 896
Default Delete columns based on a cell reference date value

corrected

Sub cus()

For i = Range("H1").Column To Worksheets("data").Range
("H1:BG1").Cells.Count
Cells(1, i).Activate
If Cells(1, i).Value < Range("WCDATA").Value Then
Cells(1, i).Columns.EntireColumn.Delete
i = i - 1
Else
Exit For
End If
Next i

End Sub

On 18 Lis, 08:59, fishy wrote:
I have a sheet titled 'data' that has source information and row 1 has
columns H to BG with dates.

On sheet 'Control' is a cell that has a free format cell for dates to be
entered. I have named this cell 'WCDATA' for ease of another piece of code.

I am tring to create a macro that will locate the date specified in WCDATA
on the data sheet and delete all columns from H until that which matches
WCDATA.

Fortunately I have been running on a test file and I have tried several
options but after considerable hair pulling am seeking assistance as am
getting close to deadline now.

Any assistance appreciated.

R


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Delete columns based on a cell reference date value

You can avoid that looping

Sub Macro8()
Dim varfound As Range
Set varfound = Worksheets("Data").Rows(1).Find(Range("wcdata"))
If Not varfound Is Nothing Then
Worksheets("Data").Range("H1", Cells(1, varfound.Column)).EntireColumn.Delete
End If
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Jarek Kujawa" wrote:

corrected

Sub cus()

For i = Range("H1").Column To Worksheets("data").Range
("H1:BG1").Cells.Count
Cells(1, i).Activate
If Cells(1, i).Value < Range("WCDATA").Value Then
Cells(1, i).Columns.EntireColumn.Delete
i = i - 1
Else
Exit For
End If
Next i

End Sub

On 18 Lis, 08:59, fishy wrote:
I have a sheet titled 'data' that has source information and row 1 has
columns H to BG with dates.

On sheet 'Control' is a cell that has a free format cell for dates to be
entered. I have named this cell 'WCDATA' for ease of another piece of code.

I am tring to create a macro that will locate the date specified in WCDATA
on the data sheet and delete all columns from H until that which matches
WCDATA.

Fortunately I have been running on a test file and I have tried several
options but after considerable hair pulling am seeking assistance as am
getting close to deadline now.

Any assistance appreciated.

R


.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 896
Default Delete columns based on a cell reference date value

thks Jacob

On 18 Lis, 10:17, Jacob Skaria
wrote:
You can avoid that looping

Sub Macro8()
Dim varfound As Range
Set varfound = Worksheets("Data").Rows(1).Find(Range("wcdata"))
If Not varfound Is Nothing Then
Worksheets("Data").Range("H1", Cells(1, varfound.Column)).EntireColumn.Delete
End If
End Sub

If this post helps click Yes
---------------
Jacob Skaria



"Jarek Kujawa" wrote:
corrected


Sub cus()


For i = Range("H1").Column To Worksheets("data").Range
("H1:BG1").Cells.Count
Cells(1, i).Activate
If Cells(1, i).Value < Range("WCDATA").Value Then
Â* Â*Cells(1, i).Columns.EntireColumn.Delete
Â* Â*i = i - 1
Else
Â* Â*Exit For
End If
Next i


End Sub


On 18 Lis, 08:59, fishy wrote:
I have a sheet titled 'data' that has source information and row 1 has
columns H to BG with dates.


On sheet 'Control' is a cell that has a free format cell for dates to be
entered. I have named this cell 'WCDATA' for ease of another piece of code.


I am tring to create a macro that will locate the date specified in WCDATA
on the data sheet and delete all columns from H until that which matches
WCDATA.


Fortunately I have been running on a test file and I have tried several
options but after considerable hair pulling am seeking assistance as am
getting close to deadline now.


Any assistance appreciated.


R


.- Ukryj cytowany tekst -


- Pokaż cytowany tekst -




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
delete columns based on value in one cell larrydave Excel Programming 8 December 11th 08 03:37 AM
Delete columns based on cell value Robert H Excel Programming 6 February 1st 07 01:40 PM
Delete Row Based On Two Columns Kris Excel Programming 8 July 6th 06 12:44 AM
How can I delete a row based on Columns H and I ICSAnalyst[_3_] Excel Programming 1 November 16th 04 10:19 AM
How can I delete a row based on Columns H and I ICSAnalyst[_4_] Excel Programming 1 November 15th 04 09:15 PM


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

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

About Us

"It's about Microsoft Excel"