Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Macro running through selected fields only

Hello,

I'm using a selectionloop macro which goes through whole column A,
activate the record if letter "y" is registered, and fullfill for that
specific record some copy/paste actions.

I want to change the macro on such a way that it runs only through
selected fields and within that selected fields look in column A and
do the actions if letter "y" is registered (For example : I have
selected record 10 till 15 -or- field B12 till B20 -or- record 10 and
with CTRL record 25 and record 30).

Can somebody help me out with a macro which fullfill my wishes.
Thanks.

Sub
LastRow = Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row
lr = LastRow
lr1 = lr + 1
co = 1
For li = lr1 To 2 Step -1
If InStr(Cells(li, co), "y") = 1 Then
Cells(li, co).Select
acr = ActiveCell.Row
Range("B" & acr).Select
act = ActiveCell.Text
'on this point the macro does some copy-paste actions to another
sheet
End If
Next li
End Sub

regards,
Johan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro running through selected fields only


Try this code


Code:
--------------------
Option Explicit
Option Compare Text
Sub y()
Dim rSearch As Range
Dim rSelect As Range
Dim cl As Range
Set rSearch = Selection
For Each cl In rSearch
If cl.Text = "y" Then
If rSelect Is Nothing Then
Set rSelect = cl
Else: Set rSelect = Union(cl, rSelect)
End If
End If
Next cl
'replace this with yopur paste code
rSelect.Select
End Sub
--------------------


--
royUK
------------------------------------------------------------------------
royUK's Profile: http://www.thecodecage.com/forumz/member.php?userid=15
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=24753

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Macro running through selected fields only

Thanks a lot,

It works fine accept one little issue.
When I select the whole record(s) or datafields in column A it works
oke, but...
when I select fields in other columns it gives an error.

Is there a possibility that the macro, where ever the selected fields
are (other columns) the macro
looks always in column A of those selected fields.

Hopely a reaction will come and help me out.

regards,
Johan
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
Running a macro from currently selected cell? GD Excel Discussion (Misc queries) 1 February 10th 09 05:11 PM
Running macro from currently selected cell? GD Excel Discussion (Misc queries) 1 February 10th 09 04:54 PM
Run a macro only for the selected fields(records) [email protected] Excel Programming 2 November 2nd 08 06:42 AM
Macro to Export Selected fields to an Existing Access Database ernie Excel Programming 1 March 13th 06 05:01 PM
Running a macro in a selected cell... Steve Excel Discussion (Misc queries) 2 January 19th 06 10:58 PM


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