Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / General Excel Questions / March 2008

Tip: Looking for answers? Try searching our database.

use active cell to determine range

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gizmo - 30 Mar 2008 16:17 GMT
I am using the following code to import record from another sheet so the
record can be modified. The user has to look at the "Records" sheet, find the
row number of the record they want to modify, move to the AddRecord sheet and
input the row number in cell "A41" and click on the ImportRecordBtn. I want
to have the user click on a record on the "Records" sheet and then click on
ImportRecordBtn on the same sheet and have the record move to the AddRecord
sheet.

Sub ImportRecordBtn()
   
   'Import data on AddRecord Sheet based on data selected from Records Sheet
   ActiveWorkbook.Unprotect Password:="xxx"
   Sheets("Records").Unprotect Password:="xxx"
   Dim LName As String
   Dim LType As String
   Dim LAffectedSystem As String
   Dim LNote As String
   Dim LHours As Integer
   Dim LModule As String
   Dim LSubAssy As String
   Dim LComponent As String
   Dim LWaferCount As String
   Dim LToolType As String
   Dim LSerNo As Integer
   Dim LResolved As String
   Dim LKeyword As String
   Dim LDept As String
   Dim LOwner As String
   Dim LFTEs As Integer
   Dim LRecordNo As String
   
   
   Dim LRow As Long
   Dim LFound As Boolean
       
       LRow = Range(A41).Address
       
       
' Move to Record sheet and record values based on row selected.
   'Sheets("Records").Activate
   'Sheets("Records").Unprotect Password:="xxx"
     
       
       LName = Range("C" & LRow).Value
       LNote = Range("D" & LRow).Value
       LOwner = Range("E" & LRow).Value
       LDept = Range("F" & LRow).Value
       LType = Range("H" & LRow).Value
       Range("I" & LRow).Value = "Yes"
       Range("I" & LRow).Font.ColorIndex = 3
       LToolType = Range("J" & LRow).Value
       LSerNo = Range("K" & LRow).Value
       LAffected = Range("L" & LRow).Value
       LModule = Range("M" & LRow).Value
       LSubAssy = Range("N" & LRow).Value
       LComponent = Range("O" & LRow).Value
       LHours = Range("P" & LRow).Value
       LWaferCount = Range("Q" & LRow).Value
       LKeyword = Range("R" & LRow).Value
       LFTEs = Range("T" & LRow).Value
       LRecordNo = Range("U" & LRow).Value
       
       
   Sheets("Records").Protect Password:="xxx"

' Move to AddRecords sheet and input data based on Records sheet and Row
selected
   Sheets("AddRecords").Visible = True
   Sheets("Records").Visible = False
   Sheets("AddRecords").Activate
   Sheets("AddRecords").Unprotect Password:="xxx"
   
       Range("B4").Value = LName
       Range("C4").Value = LToolType
       Range("D4").Value = LSerNo
       Range("E4").Value = LWaferCount
       Range("A8").Value = LType
       Range("B8").Value = LAffected
       Range("C8").Value = LModule
       Range("D8").Value = LSubAssy
       Range("E8").Value = LComponent
       Range("A12").Value = LKeyword
       Range("B12").Value = LNote
       Range("E12").Value = LHours
       Range("F12").Value = LFTEs
       Range("G12").Value = "No"
       Range("H5").Value = LDept
       Range("I5").Value = LOwner
       Range("A19").Value = LRecordNo
       
   'Clear entries from cells
       Range("E12").Value = ""
       
   Sheets("AddRecords").Protect Password:="xxx"
   ActiveWorkbook.Protect Password:="xxx"
   
End Sub
Dave Peterson - 30 Mar 2008 17:48 GMT
As long as the button is on the Records sheet, I think you could get away with
doing this:

LRow = Range("A41").Value

But maybe you could just use the row with the activecell???

LRow = activecell.row

> I am using the following code to import record from another sheet so the
> record can be modified. The user has to look at the "Records" sheet, find the
[quoted text clipped - 89 lines]
>
> End Sub

Signature

Dave Peterson

Gizmo - 31 Mar 2008 04:55 GMT
Dave,

Thank you very much.

LRow = activecell.row  did the trick.

I've been trying all sorts of combinations including  
LRow=Range("A41").Value and nothing worked.

Thanks again.

> As long as the button is on the Records sheet, I think you could get away with
> doing this:
[quoted text clipped - 98 lines]
> >
> > End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.