Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Tan Arthur via OfficeKB.com
 
Posts: n/a
Default Repeating same task for different cell

Hi All ,
I need to repeat the below task at different cell . E.g C8 ,D20 , C21 ...

Dim sRange As String
sRange = "C8"
Range(sRange).Select
If IsEmpty(ActiveCell) = True Then ?..
Else ??
End If

Would appreciate someone can help , thanks.

--
Message posted via http://www.officekb.com
  #2   Report Post  
Vikrant Vaidya
 
Posts: n/a
Default

modify this script to a function as follows

Private Function modval(row,column)
Dim sRange As String
sRange = worksheets("your worksheet name").cells(row,column)
Range(sRange).Select
If IsEmpty(ActiveCell) = True Then ?..
Else ??
End If

Then in the cell you put value which is to be manipulated just pass the row
and column to this function like
=modval(8,3) for cell c8

vikrant


"Tan Arthur via OfficeKB.com" wrote:

Hi All ,
I need to repeat the below task at different cell . E.g C8 ,D20 , C21 ...

Dim sRange As String
sRange = "C8"
Range(sRange).Select
If IsEmpty(ActiveCell) = True Then ?..
Else ??
End If

Would appreciate someone can help , thanks.

--
Message posted via http://www.officekb.com

  #3   Report Post  
JE McGimpsey
 
Posts: n/a
Default

How will you determine which cells?

If in advance, here's one way:

Public Sub test1()
Dim rCell As Range
For Each rCell In Range("C8,D20,C21")
If IsEmpty(rCell.Value) Then
'?..
Else
'??
End If
Next rCell
End Sub

If you want it to run on all selected cells:

Public Sub test2()
Dim rCell As Range
If TypeName(Selection) = "Range" Then
For Each rCell In Selection
If IsEmpty(rCell.Value) Then
'?..
Else
'??
End If
Next rCell
End If
End Sub


Note that selection/activation is not necessary. Using the range objects
directly makes your code smaller, faster, and IMO, easier to maintain.



In article ,
"Tan Arthur via OfficeKB.com" wrote:

I need to repeat the below task at different cell . E.g C8 ,D20 , C21 ...

Dim sRange As String
sRange = "C8"
Range(sRange).Select
If IsEmpty(ActiveCell) = True Then ?..
Else ??
End If

  #4   Report Post  
Tan Arthur via OfficeKB.com
 
Posts: n/a
Default

Hello McGimpsey,
thanks for your help .

--
Message posted via http://www.officekb.com
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
Maintaining cell reference after sorting GRITS Excel Discussion (Misc queries) 2 April 30th 23 07:42 PM
COPY A CONCATENATE CELL TO BLANK CELL PUTTING IN THE NEXT BLANK C. QUEST41067 Excel Discussion (Misc queries) 1 January 15th 05 09:29 PM
Delete Cell Value Based on Another Cell T or F DocuMike Excel Discussion (Misc queries) 3 January 5th 05 08:46 PM
How do I link many cells to one particular cell? justinfishman22 Excel Discussion (Misc queries) 2 January 4th 05 12:09 AM
copy a cell value not its function KC Mao Excel Discussion (Misc queries) 2 December 4th 04 04:30 AM


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