Dear Sir,
I am in learning stage of Macro ...Please let me know .

Can we use the below code for the same.

For example

sub change_value()


Dim i As Integer


For i = 1 To 7
If Cells(i, 4).Value < 0.8 Then
Cells(i, 4).Value = 0.8

End If
Next i


End Sub

Thanks in Advance.


On Thu, Jun 6, 2013 at 6:35 PM, Paul Schreiner <schreiner_p...@att.net>wrote:

> If I understand what you are asking, I would recommend something like:
>
>  Sub conditionalreplace()
>    Dim Rng as Range
>
>     For Each Rng in Range("D1:D10")
>         If Rng.Value < 0.8 Then
>             Rng.Value = .80
>         End If
>     Next
> End Sub
>
>
>
> The "Dim" statement means to "Dimension"
>
> which the way in which we "Declare" that a variable (Rng) is type "Range".
>
>
>
> *Paul*
>
> -----------------------------------------
> *“Do all the good you can,
> By all the means you can,
> In all the ways you can,
> In all the places you can,
> At all the times you can,
> To all the people you can,
> As long as ever you can.” - John Wesley
> *-----------------------------------------
>
>
>  ------------------------------
> *From:* Prafull Jadhav <prafulltjad...@gmail.com>
> *To:* excel-macros@googlegroups.com
> *Sent:* Thu, June 6, 2013 8:26:37 AM
>
> *Subject:* Re: $$Excel-Macros$$ Conditional Search & Replace
>
> Dear Sir,
> Small Question...
>
> then Sir  what is exact meaning and use of declare variable in below case?
>
> Thanks in Advance .
> Reg,
> Prafull Jadhav.
>
>
>
> On Thu, Jun 6, 2013 at 5:41 PM, Paul Schreiner <schreiner_p...@att.net>wrote:
>
>>  IF you do not utilized "Option Explicit" at the beginning of each
>> module,
>> then VBA will "automatically" declare a variable the first time it is
>> used.
>>
>> So, yes, the macro should run.
>>
>> However,
>> In my opinion, it is NEVER a good idea to create a variable that is the
>> same "name" as one of the keywords used in Excel.
>>
>> In this case, VBA is declaring a variable called "Range" as type Range.
>> and at the same time, "Range" is a method..
>> It's also curious that the "default" property of the Range object is
>> "Value".
>>
>> So
>> Range = .80
>> is the same as
>> Range.Value = .80
>> In your code, you use:
>> If Range.Value < 0.8
>>
>> yet you then use:
>> Range = .80
>>
>> it seems that the usage is inconsistent.
>>
>> hope this helps,
>>
>> Paul
>>  ------------------------------
>> *From:* Prafull Jadhav <prafulltjad...@gmail.com>
>> *To:* excel-macros@googlegroups.com
>> *Sent:* Thu, June 6, 2013 7:59:11 AM
>> *Subject:* Re: $$Excel-Macros$$ Conditional Search & Replace
>>
>> Dear XLS,
>>
>> if we not declarer variable , will code run properly .?
>>
>> suppose ...we write code as per below.
>>
>>  Sub conditionalreplace()
>>
>>              For Each Range In Range("D1:D10")
>>         If Range.Value < 0.8 Then
>>             Range = .80
>>         End If
>>     Next
>>     End Sub
>> if not ...Please explain...
>> Regards,
>> Prafull
>>
>>
>>
>> On Thu, Jun 6, 2013 at 4:21 PM, xlstime <xlst...@gmail.com> wrote:
>>
>>>  try below VBA code
>>>
>>>  Sub conditionalreplace()
>>>     Dim rng As Range
>>>              For Each rng In Range("D1:D10")
>>>         If rng.Value < 0.8 Then
>>>             rng = .80
>>>         End If
>>>     Next
>>>     End Sub
>>>
>>>
>>> .........................
>>>
>>> Enjoy
>>> Team XLS
>>>
>>>
>>>
>>> On Thu, Jun 6, 2013 at 11:18 AM, Amit Desai (MERU) <
>>> amit.de...@merucabs.com> wrote:
>>>
>>>>  Dear Friends,****
>>>>
>>>> ** **
>>>>
>>>> Do we have any functionality to do conditional search & replace...****
>>>>
>>>> ** **
>>>>
>>>> For example what if I wants to search for values less than 80% &
>>>> replace them by 80% in selected range! Do we have any features...****
>>>>
>>>> ** **
>>>>
>>>> Best Regards,****
>>>>
>>>> Amit Desai****
>>>>
>>>> ** **
>>>>
>>>> ------------------------------
>>>> Disclaimer: This message and its attachments contain confidential
>>>> information and may also contain legally privileged information. This
>>>> message is intended solely for the named addressee. If you are not the
>>>> addressee indicated in this message (or authorized to receive for
>>>> addressee), you may not copy or deliver any part of this message or its
>>>> attachments to anyone or use any part of this message or its attachments.
>>>> Rather, you should permanently delete this message and its attachments (and
>>>> all copies) from your system and kindly notify the sender by reply e-mail.
>>>> Any content of this message and its attachments that does not relate to the
>>>> official business of Meru Cab Company Pvt. Ltd. must be taken not to have
>>>> been sent or endorsed by any of them. Email communications are not private
>>>> and no warranty is made that e-mail communications are timely, secure or
>>>> free from computer virus or other defect.
>>>>
>>>> --
>>>> Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be?
>>>> It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @
>>>> https://www.facebook.com/discussexcel
>>>>
>>>> FORUM RULES
>>>>
>>>> 1) Use concise, accurate thread titles. Poor thread titles, like Please
>>>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
>>>> will not get quick attention or may not be answered.
>>>> 2) Don't post a question in the thread of another member.
>>>> 3) Don't post questions regarding breaking or bypassing any security
>>>> measure.
>>>> 4) Acknowledge the responses you receive, good or bad.
>>>> 5) Jobs posting is not allowed.
>>>> 6) Sharing copyrighted material and their links is not allowed.
>>>>
>>>> NOTE : Don't ever post confidential data in a workbook. Forum owners
>>>> and members are not responsible for any loss.
>>>> ---
>>>> You received this message because you are subscribed to the Google
>>>> Groups "MS EXCEL AND VBA MACROS" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to excel-macros+unsubscr...@googlegroups.com.
>>>> To post to this group, send email to excel-macros@googlegroups.com.
>>>> Visit this group at http://groups.google.com/group/excel-macros?hl=en.
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>>
>>>>
>>>
>>>  --
>>> Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be?
>>> It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @
>>> https://www.facebook.com/discussexcel
>>>
>>> FORUM RULES
>>>
>>> 1) Use concise, accurate thread titles. Poor thread titles, like Please
>>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
>>> will not get quick attention or may not be answered.
>>> 2) Don't post a question in the thread of another member.
>>> 3) Don't post questions regarding breaking or bypassing any security
>>> measure.
>>> 4) Acknowledge the responses you receive, good or bad.
>>> 5) Jobs posting is not allowed.
>>> 6) Sharing copyrighted material and their links is not allowed.
>>>
>>> NOTE : Don't ever post confidential data in a workbook. Forum owners and
>>> members are not responsible for any loss.
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "MS EXCEL AND VBA MACROS" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to excel-macros+unsubscr...@googlegroups.com.
>>> To post to this group, send email to excel-macros@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/excel-macros?hl=en.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>> --
>> Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s
>> =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @
>> https://www.facebook.com/discussexcel
>>
>> FORUM RULES
>>
>> 1) Use concise, accurate thread titles. Poor thread titles, like Please
>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
>> will not get quick attention or may not be answered.
>> 2) Don't post a question in the thread of another member.
>> 3) Don't post questions regarding breaking or bypassing any security
>> measure.
>> 4) Acknowledge the responses you receive, good or bad.
>> 5) Jobs posting is not allowed.
>> 6) Sharing copyrighted material and their links is not allowed.
>>
>> NOTE : Don't ever post confidential data in a workbook. Forum owners and
>> members are not responsible for any loss.
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "MS EXCEL AND VBA MACROS" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to excel-macros+unsubscr...@googlegroups.com.
>> To post to this group, send email to excel-macros@googlegroups.com.
>> Visit this group at http://groups.google.com/group/excel-macros?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>> --
>> Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s
>> =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @
>> https://www.facebook.com/discussexcel
>>
>> FORUM RULES
>>
>> 1) Use concise, accurate thread titles. Poor thread titles, like Please
>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
>> will not get quick attention or may not be answered.
>> 2) Don't post a question in the thread of another member.
>> 3) Don't post questions regarding breaking or bypassing any security
>> measure.
>> 4) Acknowledge the responses you receive, good or bad.
>> 5) Jobs posting is not allowed.
>> 6) Sharing copyrighted material and their links is not allowed.
>>
>> NOTE : Don't ever post confidential data in a workbook. Forum owners and
>> members are not responsible for any loss.
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "MS EXCEL AND VBA MACROS" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to excel-macros+unsubscr...@googlegroups.com.
>> To post to this group, send email to excel-macros@googlegroups.com.
>> Visit this group at http://groups.google.com/group/excel-macros?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
> --
> Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s
> =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @
> https://www.facebook.com/discussexcel
>
> FORUM RULES
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
> will not get quick attention or may not be answered.
> 2) Don't post a question in the thread of another member.
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
> 4) Acknowledge the responses you receive, good or bad.
> 5) Jobs posting is not allowed.
> 6) Sharing copyrighted material and their links is not allowed.
>
> NOTE : Don't ever post confidential data in a workbook. Forum owners and
> members are not responsible for any loss.
> ---
> You received this message because you are subscribed to the Google Groups
> "MS EXCEL AND VBA MACROS" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to excel-macros+unsubscr...@googlegroups.com.
> To post to this group, send email to excel-macros@googlegroups.com.
> Visit this group at http://groups.google.com/group/excel-macros?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
> --
> Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s
> =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @
> https://www.facebook.com/discussexcel
>
> FORUM RULES
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
> will not get quick attention or may not be answered.
> 2) Don't post a question in the thread of another member.
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
> 4) Acknowledge the responses you receive, good or bad.
> 5) Jobs posting is not allowed.
> 6) Sharing copyrighted material and their links is not allowed.
>
> NOTE : Don't ever post confidential data in a workbook. Forum owners and
> members are not responsible for any loss.
> ---
> You received this message because you are subscribed to the Google Groups
> "MS EXCEL AND VBA MACROS" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to excel-macros+unsubscr...@googlegroups.com.
> To post to this group, send email to excel-macros@googlegroups.com.
> Visit this group at http://groups.google.com/group/excel-macros?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to