|
-
Nov 23rd, 2011, 04:44 AM
#1
Thread Starter
New Member
[RESOLVED] [Excel] Code to check cells into activeworkbook
Hi,
I'm trying to get a code to check 7 specific cells into my active workbook and if any of them has data in them to insert "X" into my closed workbook. This is part of another chunk of code as well to populate the closed workbook.
Code:
Dim wbksour As Workbook
Dim wbkdes As Workbook
Dim strSecondFile As String
Dim wksh As Worksheet
strSecondFile = "\\prc2507et001\IRFSSMP_31\IRFSS\_MAINTENANCE\Récup Info.xls" 'Path for destination document
Set wbksour = ActiveWorkbook() 'Use the activeworkbook regardless of name
Set wbkdes = Workbooks.Open(strSecondFile) 'Open the source workbook to copy the selected cells below
Screenrefresh = False
nextrow = wbkdes.Sheets("Récup Info").Cells(wbkdes.Sheets("Récup Info").Rows.Count, 1).End(xlUp).Row + 1 'Select next row
wbkdes.Sheets("Récup Info").Cells(nextrow, 1) = wbksour.Sheets("Bon de Travaux").Cells(28, 16) 'Copies P28 into Cell A2 of wbkdes.Sheets("Récup Info")
wbkdes.Sheets("Récup Info").Cells(nextrow, 2) = wbksour.Sheets("Bon de Travaux").Cells(6, 6) 'Copies F6 into Cell B2 of wbkdes.Sheets("Récup Info")
If Not Application.Intersect(Target, wrksour.Range("H53,H55,H57,H59,H61,H63,H65")) Is Nothing Then
If Target = "" Then
wbkdes.Sheets("Récup Info").Cells(nextrow, 20) = ""
Else
wbkdes.Sheets("Récup Info").Cells(nextrow, 21) = "X"
End If
End If
wbkdes.Save 'Save the Destination worksheet
wbkdes.Close 'Close the Destination worksheet
So if the cells H53,H55,H57,H59,H61,H63,H65 have either a "X" or nothing it then runs the code.
I'm having a problem with "If Not Application.Intersect(Target, ". I think the problem is that it's trying to run those lines of codes on the destination workbook.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|