I have two sets of code
As you can see, this sets my desired active cells to be the same as the values from sheet “Cansim”. This works great!For Each d In Range("Prov1") d.Select ActiveCell.Offset(2, 0).Select ActiveCell.FormulaR1C1 = "=Cansim!R[-1]C" ActiveCell.Offset(14, 0).Select ActiveCell.FormulaR1C1 = "=Cansim!R[-14]C" ActiveCell.Offset(14, 0).Select ActiveCell.FormulaR1C1 = "=Cansim!R[-27]C" ActiveCell.Offset(14, 0).Select ActiveCell.FormulaR1C1 = "=Cansim!R[-40]C" ActiveCell.Offset(14, 0).Select ActiveCell.FormulaR1C1 = "=Cansim!R[-53]C" Next d
This code however, does not:
This code is trying to find the proper identifier but it cannot. I’ve figured out it is because the identifier to be found is a reference to a value, not the value itself. Is there a way to have the .Find method see the value of the cells instead of the reference?For Each c In Range("WPGCansim") c.Select Application.Worksheets("Insert").Select Set r = Worksheets("Insert").Range("CansimSourceNo").Find(c) If Not r Is Nothing Then r.Select
Sorry if this makes no sense but me brain is all tricksee because of dealing with would-be car thieves last night and I’m downright tired. If needed I can upload the workbook.
Thanks
Last edited by Mordred; 08-13-2010 at 03:44 PM.
Please leave a message after the beep!
Well c.value will return the value of the top left-most cell in any range, but it's the default return if you don't specify a range property anyway. So, for example, Msgbox c, will return the value of c.
Perhaps you should tell us what problem you're experiencing with this code. Other than the fact you've got two .select statements in there that aren't needed I can't see any immediate issues with it.
The first code snippet retrieves all of the identifiers and places them properly into the Insert sheet (which is the data that comes from our source). I've done this because our data sheets use identifiers to fill in the data values from the source and the source does not supply the identifiers on their data tables.
The second code is from a sub that finds the identifiers from the Insert sheet based on the identifiers from our data sheet so that it can copy the data from the insert and paste it into our data sheets.
The problem is, the second snippet of code does not find the values in each cell in the Insert sheet. The first identifier it should find looks like this on the sheet: v735047. But, it is actually a reference that reads: =Cansim!L3. I think it is because it is a reference and not and actual value that the second code won't read it. Am I making sense or do you want to see the workbook?
Please leave a message after the beep!
I don't quite understand your explanation so I'm wondering why you are putting a formula into the cells instead of the actual value:
??For Each d In Range("Prov1") d.Offset(2, 0).Value = Sheets("Cansim").Cells(d.Row - 1).Value etc
---
Ben Van Johnson
I've uploaded the workbook so you can get a visual of what I am doing.
Please leave a message after the beep!
Now that you mention it proton, maybe that is what I will do. I'll just copy each identifier over instead. I'll give it a go and let you know how it.....goes?!![]()
Please leave a message after the beep!
I don't know and I don't think I am apt to understand today. I don't really want to copy each and every cell and then paste it into the Insert sheet because it appears like it will take far too much coding.
Please leave a message after the beep!
I tried your code proton and it copies blank values based on the same row criteria as: R[-1]C
Please leave a message after the beep!
You need to search the values not the formulas:
Set r = Worksheets("Insert").Range("CansimSourceNo").Find(what:=c, LookIn:=xlValues)
That did it romperstomper. Thank you so much.
Please leave a message after the beep!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks