Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 465
Default Changing cell content on n auto-filtered column



Hi All

I use this code to identify the lowest number in a column , and then
offer to change it :

Dim TheColumn As Variant
Dim TheRange As String
Dim TheMin As Variant
Dim TheNewValue As Variant
Dim OriginalRange As String
Dim OriginalCell As String

On Error GoTo Quitter

Application.ScreenUpdating = True
OriginalRange = Selection.Address
OriginalCell = ActiveCell.Address


'UnRem / Rem next line to have a popup ask for the column

TheColumn = InputBox(vbCr & "Change lowest price in which column?",
"Price Variation")


'OR UnRem / Rem next two lines to have macro work on an
already-selected or highlighted column

' TheColumn = Left(OriginalCell, _
' InStr(2, OriginalCell, "$") - 1)


If TheColumn < "" Then
TheRange = TheColumn & ":" & TheColumn
TheMin = Application.WorksheetFunction. _
Min(Range(TheRange))
TheNewValue = InputBox(vbCr & "Minimum value found was " & _
TheMin & " ...." & vbCr & vbCr & "Enter value to replace.",
"Price Variation", TheMin)
If TheNewValue < "" Then
Range(TheRange).Select
Selection.Replace What:=TheMin, _
Replacement:=TheNewValue, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
MatchCase:=False, _
SearchFormat:=False, _
ReplaceFormat:=False
Else
MsgBox "No input, operation cancelled."
End If

Range(OriginalRange).Select
Range(OriginalCell).Activate
Else
MsgBox "No input, quitting."
End If
Quitter:
Application.ScreenUpdating = True

Selection.NumberFormat = "0.00"

End Sub


This works fine on an unfiltered column.

Unfortunately when I try to apply it to column where I have used
auto-filter it no longer works properly.

Can someone suggest an amendment to the above code so that it only works
on the auto-filtered cells?

Grateful for any help.

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,872
Default Changing cell content on n auto-filtered column

Hi Colin,

Am Thu, 12 Apr 2012 21:19:29 +0100 schrieb Colin Hayes:

TheMin = Application.WorksheetFunction. _
Min(Range(TheRange))


try:
TheMin=Application.WorksheetFunction. _
Subtotal(5,Range(TheRange))


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 465
Default Changing cell content on n auto-filtered column

In article , Claus Busch
writes
Hi Colin,

Am Thu, 12 Apr 2012 21:19:29 +0100 schrieb Colin Hayes:

TheMin = Application.WorksheetFunction. _
Min(Range(TheRange))


try:
TheMin=Application.WorksheetFunction. _
Subtotal(5,Range(TheRange))


Regards
Claus Busch


Hi Claus

Thanks for that - it works perfectly on a filtered column.

Will this work equally well on an unfiltered column?

If so I can change the macro to your suggestion permanently as it would
then work in either circumstance.


Best Wishes
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,872
Default Changing cell content on n auto-filtered column

Hi Colin,

Am Thu, 12 Apr 2012 22:01:20 +0100 schrieb Colin Hayes:

Will this work equally well on an unfiltered column?


yes, it works also in unfiltered column


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 465
Default Changing cell content on n auto-filtered column

In article , Claus Busch
writes
Hi Colin,

Am Thu, 12 Apr 2012 22:01:20 +0100 schrieb Colin Hayes:

Will this work equally well on an unfiltered column?


yes, it works also in unfiltered column


Regards
Claus Busch



HI

OK that's fine. Thanks for getting back to confirm.

Grateful for your time and expertise.

Best Wishes
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
Changing the cell format doesn't change existing cell content Kate Excel Discussion (Misc queries) 2 January 14th 10 04:44 PM
Auto delete cell content [email protected] Excel Discussion (Misc queries) 1 March 13th 07 01:43 PM
Changing cell colour depending on content?? Simon Lloyd[_768_] Excel Programming 5 June 15th 06 12:48 PM
Changing row content with single cell click aussiemike Excel Discussion (Misc queries) 2 May 25th 06 06:37 AM
changing font color of cell content Donald Stockton Excel Programming 8 March 9th 06 05:50 PM


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