I just sent you Kelly an e-mail on what the file looks like...take a look and let me know.
THANKS!
Main Topics
Browse All TopicsOK...please be patient and try to understand what I am doing...
I have a workbook with data that is imported from a CSV file in which I am using VLOOKUP to obtain data based on a certain criteria (whatever is in a certain cell - this does change through the sheet). So I recorded a macro and edited so that it has offsetting including.....
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(R[-1]C[-1],'Impo
ActiveCell.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(R[-2]C[-1],'Impo
ActiveCell.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(R[-3]C[-1],'Impo
That's for one group of records...I need for it to copy down pasting special (values ONLY) up until row 3000 - 1) HOW IS THAT DONE?
Secondly, when I go to run the above macro on day 2and so on (in the consecutive columns) it wants to record it the column I recorded the macro in.... - 2) HOW DO i CORRECT THAT
NOTE: I will be monitoring these records for the next 6 months.....
ANY AND ALL HELP WOULD BE GREATLY APPRECIATED!!!
THANKS!
Joshua Dumas
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi Joshua,
First of all hear is an easier way to insert your formula (3000 being the amount of rows to add the formula
ActiveCell.FormulaR1C1 = "=VLOOKUP(R[-1]C8,'Importe
Selection.AutoFill Destination:= _
Range(ActiveCell.Address, ActiveCell.Offset(3000, 0).Address)
And how to paste values:
Columns(ActiveCell.Column)
Columns(ActiveCell.Column)
Application.CutCopyMode = False
To Get the correct column you could perform a loop that will skip across each column and stop at the first "Blank" cell it can find:
Range("A1").Select
Do Until ActiveCell.Value = ""
Selection.Offset(0,1).Sele
Loop
Reg's
m8rix
m8rix:
I got your suggestions and the skipping across the columns works great, but I have a problem with the other stuff:
In my macro this is what I have:
Range("B4").Select
Do Until ActiveCell.Value = ""
Selection.Offset(0, 1).Select
Loop
ActiveCell.FormulaR1C1 = "=VLOOKUP(R[-1]C[-1],'Impo
Selection.AutoFill Destination:= _
Range(ActiveCell.Address, ActiveCell.Offset(3000, 0).Address)
Columns(ActiveCell.Column)
Columns(ActiveCell.Column)
Application.CutCopyMode = False
The problem is that when (ActiveCell.FormulaR1C1 = "=VLOOKUP(R[-1]C[-1],'Impo
Let me know!
THANKS!
Hi Joshua,
Ok.. To change the "Lookup" range to columns "C" to "F" use this:
ActiveCell.FormulaR1C1 = "=VLOOKUP(R[-1]C[-1],'Impo
I will give you an explanation so you can make your own changes in the future:
Assume that the active cell reference is currently "F5"
R1C1 = "$A$1" (we are specifying the exact location by grid reference "Row 1, Column 1")
R[0]C[0] = "F5" (we are specifying an offset of zero rows and zero columns from the active cell)
R[-4]C[-5] = "A1" (we are specifying an offset of -4 rows and -5 columns from the active cell)
R[0]C1 = "$A5" (The row will always be the same as the active cell the column will always be "A")
R1C[0] = "F$1" (The row will always be "Row 1" the column will always be the same as the active column)
Column references:
C1 = A, C2 = B, C3 = C, C26 = Z, C27 = AA, etc...
As I am not too sure of what you mean here:
> as the next day needs to put to A3+4 (as it is in chunks of 4) - NAME, ALLOC, USED, LOCKED
I hope that the explanation I have given will help you work it out. If not I will try and give you some more assistance.
Reg's
m8rix ;o)
Actually this is what I have as a macro so far:
Sub Daily_Update()
'
' Daily Update Macro
' Macro created 5/20/2003 by Joshua M. Dumas & Sean Jefferson
'
Range("B4").Select
Do Until ActiveCell.Value = ""
Selection.Offset(0, 1).Select
Loop
Do Until ActiveCell.Offset(R0, c - 1) = ""
For A = 1 To 1
ActiveCell.FormulaR1C1 = "=VLOOKUP(R[-1]C1,'Importe
ActiveCell.Offset(1, 0).Select
Next A
For B = 1 To 1
ActiveCell.FormulaR1C1 = "=VLOOKUP(R[-2]C1,'Importe
ActiveCell.Offset(1, 0).Select
Next B
For c = 1 To 1
ActiveCell.FormulaR1C1 = "=VLOOKUP(R[-3]C1,'Importe
ActiveCell.Offset(2, 0).Select
Next c
Loop
Columns(ActiveCell.Column)
Columns(ActiveCell.Column)
Application.CutCopyMode = False
End Sub
This Do Until ActiveCell.Offset(R0, c - 1) = "" needs to look at the cell in column A - whatever row its in (so Ax) x being the row that is active and see if their is text...if so, then run this:
For A = 1 To 1
ActiveCell.FormulaR1C1 = "=VLOOKUP(R[-1]C1,'Importe
ActiveCell.Offset(1, 0).Select
Next A
For B = 1 To 1
ActiveCell.FormulaR1C1 = "=VLOOKUP(R[-2]C1,'Importe
ActiveCell.Offset(1, 0).Select
Next B
For c = 1 To 1
ActiveCell.FormulaR1C1 = "=VLOOKUP(R[-3]C1,'Importe
ActiveCell.Offset(2, 0).Select
Next c
Loop
Any idea?
THANKS for all your help in advance!
Joshua
Actually this is how my macro is:
Sub Daily_Update()
'
' Daily Update Macro
'
Range("B4").Select
Do Until ActiveCell.Value = ""
Selection.Offset(0, 1).Select
Loop
' Do Until ActiveCell.Value(r0, c - 1) = " "
For Z = 1 To 100
For A = 1 To 1
ActiveCell.FormulaR1C1 = "=VLOOKUP(R[-1]C1,'Importe
ActiveCell.Offset(1, 0).Select
Next A
For B = 1 To 1
ActiveCell.FormulaR1C1 = "=VLOOKUP(R[-2]C1,'Importe
ActiveCell.Offset(1, 0).Select
Next B
For c = 1 To 1
ActiveCell.FormulaR1C1 = "=VLOOKUP(R[-3]C1,'Importe
ActiveCell.Offset(2, 0).Select
Next c
'Loop
Next
Columns(ActiveCell.Column)
Columns(ActiveCell.Column)
Application.CutCopyMode = False
End Sub
BUT I DONT WANT IT TO DO IF THEIR ISN'T DATA IN COLUMN A, ROW X (X BEING WHICH EVER ROW IT'S ON)
any idea?
Joshua
why on earth do you have For A = 1 to 1, etc. in there?
This doesn't do anything at all (except set A to 1, then increment it and stop looping).
Also, it's generally not a good idea to use "ActiveCell" and "Select" all over the place. You can typically change your code to not change the current selection. Then it doesn't "forget" where you were, and it also doesn't take nearly as long to execute (not as much screen updating and moving around).
(from loop A)
ActiveCell.FormulaR1C1 = "=VLOOKUP(R[-1]C1,'Importe
ActiveCell.Offset(1, 0).Select
you can remove the loop (For and Next lines) and change the code for the outer For loop to:
(make sure that ActiveCell on entry to this loop points to the cell with the information in it (the FQDN))
z = 0
Do While Not IsEmpty(ActiveCell.Offset(
For i = 1 to 3
ActiveCell.Offset(z*4, i).FormulaR1C1 = "=VLOOKUP(R[-"&i&"]C1,'Imp
Next i
Loop
I still wonder why you weren't using my code... With my code, you don't even need to worry about these formulas, everything is populated automatically. Can you give me a hint why you don't like it?
Ok, let's try this again... Before the line "Loop", that is.
the final loop should look like
z = 0
Do While Not IsEmpty(ActiveCell.Offset(
For i = 1 to 3
ActiveCell.Offset(z*4, i).FormulaR1C1 = "=VLOOKUP(R[-"&i&"]C1,'Imp
Next i
z = z + 1
Loop
Sorry for the confusion.
schutnik:
Here is my xls workbook I am working on - with data changed to protect our private data - http://www.joshuadumas.com
THANKS!
Here's the complete contents of that macro adjusted to fix some problems... I ask again, why aren't you using the other code I sent you? It does everything for you and even keeps track of where to copy the data to the next time. It'll even add newly appearing IPs to the list and create the state pages for you automatically.
Range("A3").Select
z = 0
Do While Not IsEmpty(ActiveCell.Offset(
For i = 1 To 3
ActiveCell.Offset(z * 4 + i, 1).FormulaR1C1 = "=VLOOKUP(R[-" & i & "]C1,'Imported Data'!C3:C6," & (i + 1) & ",FALSE)"
Next i
z = z + 1
Loop
Columns(ActiveCell.Column)
Columns(ActiveCell.Column)
Application.CutCopyMode = False
wow...
I can't believe it's that slow (well, actually I can, but I'm not willing to take the time to make it faster).
This should fix your problems with not moving over and copying the wrong cells.
Range("A3").Select
x = Range("A4").End(xlToRight)
If x >= 255 Then x = 2
z = 0
Do While Not IsEmpty(ActiveCell.Offset(
For i = 1 To 3
ActiveCell.Offset(z * 4 + i, x).FormulaR1C1 = "=VLOOKUP(R[-" & i & "]C1,'Imported Data'!C3:C6," & (i + 1) & ",FALSE)"
Next i
z = z + 1
Loop
Columns(ActiveCell.Column + x).Copy
Columns(ActiveCell.Column + x).PasteSpecial Paste:=xlValues
Application.CutCopyMode = False
Cool......great...all done!....in the next day or so I am going to post another question asking to see how would I go about (meaning the best way) to compare records in Imported Data and if it's not in any of the sheets, then copy that row to a newly made sheet, or would be best to copy to the correct sheet...any idea?
This is where the code that I used before comes in. Unfortunately, as you said, it's pretty slow.
No matter what you do, I think you'll find that this will be slow as well. It may be best to try to modify the code I gave you before so that it's using Excel functions to do the lookups rather than the VB loops that it's currently using.
Kelly
Business Accounts
Answer for Membership
by: schutnikPosted on 2003-05-20 at 12:23:13ID: 8552989
Let's try this again...
Maybe you can give me an idea of what the spreadsheet should look like?
Also, you just want to copy and paste as values? You only need the formula in one place, then you want a copy of the values everywhere else?
do you have someplace to which you can post the files? Send me an email if you like - kellyleahy@swbell.net
Kelly