![]() |
|
|
|
#1
|
|||
|
|||
|
Hi All,
I'm trying to get the code below to run via a button click only when the active/selected cell is within a certain range. Currently that is between B2 and X5000, this is were I have customer data, and not if the cursor is anywere else on the sheet. I have tried - If Sheets("Clipsal Customer").Range.Selection("A4:Z5000") Then, but this throws up the error. Also tried to use If Not Intersect(Target, Sh.Range("A4:A5000")) Is Nothing Then... but can't get that to work either. W hat I need is code that first checks if the currently selected cell is within the desiered range then run the code. Any help is appriciated. Code:
Sub button_click1()
Sheets("Payment Advice").Range("B3") = Date
Sheets("Payment Advice").Range("B4") = Range("a" & Mid(ActiveCell.Address, 4, 4))
Sheets("Payment Advice").Range("B5") = Range("g" & Mid(ActiveCell.Address, 4, 4))
Sheets("Payment Advice").Range("B6") = Range("h" & Mid(ActiveCell.Address, 4, 4))
Sheets("Payment Advice").Range("B7") = Range("i" & Mid(ActiveCell.Address, 4, 4))
Sheets("Payment Advice").Range("B8") = Range("j" & Mid(ActiveCell.Address, 4, 4))
Sheets("Payment Advice").Range("B9") = Range("k" & Mid(ActiveCell.Address, 4, 4))
Sheets("Payment Advice").Select
End Sub
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| EXCEL 2016 - merging multiple selected cells | kevin.suh | Excel | 2 | 03-28-2017 07:01 AM |
Word - Resize image to specified selected cells' dimensions
|
FaizanRoshan | Word VBA | 7 | 10-18-2015 03:34 PM |
Code that will run when a cells value is changed.
|
DonJohns1 | Excel Programming | 2 | 04-15-2015 10:48 AM |
Auto repeat selected cells from tables into a summary
|
AdieReeves | Word Tables | 7 | 10-22-2014 07:59 AM |
| How to keep orientation when printing Selected Cells | punkrae | Excel | 1 | 04-09-2012 05:32 PM |