Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default removing data based on other cell information

I've created the following macro that removes data based on ofther
cell information. This is similar to duplicate row code, but I'm
looking to define which columns I evaluate. Currently, this macro
looks at just column A or 1. I need it to look at column A, C, F &
G. My question is more syntax based I believe as I'm at a beginner
level in creating VB/Macro code; otherwise this is working as needed -
can anyone assist on the range on this one?

'Removing Dupicates
Dim rng As Range
Dim i As Integer
Set rng = Range(Cells(1, 1), Cells(1, 1).End(xlDown))
For i = rng.Rows(rng.Rows.Count).Row To rng.Row + 1 Step -1
If Cells(i, 1).Value = Cells(i - 1, 1) Then
Cells(i, 6).ClearContents
Cells(i, 7).ClearContents
Cells(i, 8).ClearContents
Cells(i, 9).ClearContents
End If
Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default removing data based on other cell information

On Sep 11, 10:41*am, S Himmelrich wrote:
I've created the following macro that removes data based on ofther
cell information. *This is similar to duplicate row code, but I'm
looking to define which columns I evaluate. *Currently, this macro
looks at just column A or 1. *I need it to look at column A, C, F &
G. *My question is more syntax based I believe as I'm at a beginner
level in creating VB/Macro code; otherwise this is working as needed -
can anyone assist on the range on this one?

'Removing Dupicates
* * Dim rng As Range
* * Dim i As Integer
* * Set rng = Range(Cells(1, 1), Cells(1, 1).End(xlDown))
* * For i = rng.Rows(rng.Rows.Count).Row To rng.Row + 1 Step -1
* * If Cells(i, 1).Value = Cells(i - 1, 1) Then
* * Cells(i, 6).ClearContents
* * Cells(i, 7).ClearContents
* * Cells(i, 8).ClearContents
* * Cells(i, 9).ClearContents
* * End If
Next



Hello:

Try this example, it selects multiple separate columns.

Sub RngSelect()
Dim Rng2 As Range

Set Rng2 = Union(Range("A:A"), Range("L:L"), Range("F:F"),
Range("S:S"))
Rng2.Select
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default removing data based on other cell information

This will process the cells in columns A, C, F, and G: what wasn't clear was if you wanted to clear
the cells relative the those cells or always from the same columns: F, G, H, and I.

Dim rng As Range
Dim i As Integer
Dim j As Variant
For Each j In Array(1, 3, 6, 7)
Set rng = Range(Cells(1, j), Cells(Rows.Count, j).End(xlUp))
For i = rng.Rows(rng.Rows.Count).Row To rng.Row + 1 Step -1
If Cells(i, 1).Value = Cells(i - 1, 1).Value Then
Cells(i, 6).ClearContents
Cells(i, 7).ClearContents
Cells(i, 8).ClearContents
Cells(i, 9).ClearContents
End If
Next i
Next j


--
HTH,
Bernie
MS Excel MVP


"S Himmelrich" wrote in message
...
I've created the following macro that removes data based on ofther
cell information. This is similar to duplicate row code, but I'm
looking to define which columns I evaluate. Currently, this macro
looks at just column A or 1. I need it to look at column A, C, F &
G. My question is more syntax based I believe as I'm at a beginner
level in creating VB/Macro code; otherwise this is working as needed -
can anyone assist on the range on this one?

'Removing Dupicates
Dim rng As Range
Dim i As Integer
Set rng = Range(Cells(1, 1), Cells(1, 1).End(xlDown))
For i = rng.Rows(rng.Rows.Count).Row To rng.Row + 1 Step -1
If Cells(i, 1).Value = Cells(i - 1, 1) Then
Cells(i, 6).ClearContents
Cells(i, 7).ClearContents
Cells(i, 8).ClearContents
Cells(i, 9).ClearContents
End If
Next



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default removing data based on other cell information

How would this fit into my current macro?

On Sep 11, 12:59*pm, wrote:
On Sep 11, 10:41*am, S Himmelrich wrote:





I've created the following macro that removes data based on ofther
cell information. *This is similar to duplicate row code, but I'm
looking to define which columns I evaluate. *Currently, this macro
looks at just column A or 1. *I need it to look at column A, C, F &
G. *My question is more syntax based I believe as I'm at a beginner
level in creating VB/Macro code; otherwise this is working as needed -
can anyone assist on the range on this one?


'Removing Dupicates
* * Dim rng As Range
* * Dim i As Integer
* * Set rng = Range(Cells(1, 1), Cells(1, 1).End(xlDown))
* * For i = rng.Rows(rng.Rows.Count).Row To rng.Row + 1 Step -1
* * If Cells(i, 1).Value = Cells(i - 1, 1) Then
* * Cells(i, 6).ClearContents
* * Cells(i, 7).ClearContents
* * Cells(i, 8).ClearContents
* * Cells(i, 9).ClearContents
* * End If
Next


Hello:

Try this example, it selects multiple separate columns.

Sub RngSelect()
Dim Rng2 As Range

Set Rng2 = Union(Range("A:A"), Range("L:L"), Range("F:F"),
Range("S:S"))
Rng2.Select
End Sub- Hide quoted text -

- Show quoted text -


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
looking up cell value based off of row and column information rsetzer Excel Discussion (Misc queries) 1 June 13th 07 12:40 AM
Transfer single cell information to specific cell based on user criteria RoVo Excel Programming 0 May 31st 06 04:20 PM
Removing a Row based on a cell value harpscardiff Excel Discussion (Misc queries) 4 February 10th 06 01:14 PM
Auto-fill cell based on adjacent cell information.. sans Excel Worksheet Functions 1 October 17th 05 11:38 PM
HOW DO I HAVE A CELL DISPLAY INFORMATION BASED ON 2 OTHER CELLS CC Excel Worksheet Functions 1 August 12th 05 05:34 AM


All times are GMT +1. The time now is 03:29 PM.

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"