My excel 2013 keep crashing whenever i run this macro .
Is there something wrong with my code that crashes my excel .
Please help ,thank you
![]()
Please Login or Register to view this content.
My excel 2013 keep crashing whenever i run this macro .
Is there something wrong with my code that crashes my excel .
Please help ,thank you
![]()
Please Login or Register to view this content.
Last edited by fluffyvampirekitten; 07-06-2015 at 06:00 AM.
Hi, your mistake is with the Colums "P " select and the Range("P3 " & MaxRowNum)
The macro could be simplified and I think this will do the job
![]()
Please Login or Register to view this content.
---
Hans
"IT" Always crosses your path!
May the (vba) code be with you... if it isn't; start debugging!
If you like my answer, Click the * below to say thank-you
It didn't work. It keep processing and it slow downs my laptop
![]()
I have added a few codes. I'm still facing the same problem .
![]()
Please Login or Register to view this content.
Last edited by fluffyvampirekitten; 07-06-2015 at 06:00 AM.
Of course it slows down your laptop or anything you're using, yo address the file MISSINGUSERNAMEDEPT in every loop.
Yoiu'll have to think up another strategy![]()
Do you think I can use "For Each Loop"?
you are inserting vlookup for the row with not indicated but then your filling down the formula anyway? and then your looping it for each row?
either remove the autofill or just autofill without loop?
also since your using a do while loop...is your rownum even incrementing?
If you are satisfied with the solution(s) provided, please mark your thread as Solved.
Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.
also this
seems like an awfully complicated way to find maxrow![]()
Please Login or Register to view this content.
unless your data structure absolute calls for it...
is there a specific reason why did not you take up the suggestion provided by Keebellah
![]()
Please Login or Register to view this content.
I tried out the code given by Keebellah but it keep processing and wont stop.
My idea is to find the row which displays "Not indicated" under UserName & Dept Column in SIMPAT file.
And then open up another workbook called MISSINGUSERNAMEDEPT to find the UserName & Dept using the VLOOKUP function.
Hence , If data(UserName/Dept) is found from the MISSINGUSERNAMEDEPT , this data will be pasted over in the SIMPAT file else "NOT INDICATED" .
your vlookup is the error
this formula
generates this![]()
Please Login or Register to view this content.
you cannot vlookup a column onto another column![]()
Please Login or Register to view this content.
also your missing sheet name
your formula should look something more like
![]()
Please Login or Register to view this content.
if your idea is to only update rows with not indicated then you shouldnt autofill at all
autofill will over write every row from 3 to maxrow and you are doing it every single time
your logic for the formula needs to be updated to only take in the rownum
however since your using do/while loop and not incrementing rownum...condition ofwill never be met![]()
Please Login or Register to view this content.
This is example of what it could look like
i dont know what your sheet name is called for your vlookup
edit sheet1 to whatever your sheet name is on the MISSINGUSERNAMEDEPT file
i also assumed C1:C5 for your vlookup as i dont know which column your starting from or ending
change this to suit your needs
C1:C5 = A:E
i assume your maxrownum is working correctly....![]()
Please Login or Register to view this content.
Also, note that:
Destination:=Range("P3:Q " & MaxRowNum) has a space after the Q, that's not allowed "P3:Q n" is not a valid address.
Ben Van Johnson
you are using FormulaR1C1 method
i assume because you just recorded marco and used whatever it gave you and tried to amend it
thats ok....its how i learnt also
R = Row
C = Column
R(0)C(-3) = 0 rows, 3 columns back..relative to your range
take this line of code
and assuming rownum is 30
range would (P30)![]()
Please Login or Register to view this content.
RC[-3] = p30 + zero rows + (- 3 columns) = M30
explained from above C1:C5 = A:E
the formula now reads
vlookup(m30,[Workbook]Worksheet!A:E,2,0)
more reading about it can be found here
https://excelmate.wordpress.com/2013...e-style-vs-a1/
alternatively don't use R1C1 just use .formula instead
![]()
Please Login or Register to view this content.
you want this in built into your macro or are you going to just use it once?Could i ask one more thing , Is it possible to replace "#N/A" to "NOT INDICATED" ?
if only once then i suggest you just highlight the column
Ctrl+H
Find "#n/a"
Replace with "NOT INDICATED"
if you want it part of the code
add two more IF blocks![]()
Please Login or Register to view this content.
Last edited by fluffyvampirekitten; 07-07-2015 at 02:50 AM.
forgot #N/A has special rules -
reading here if your interested
change code to
![]()
Please Login or Register to view this content.
RC[-3] means the cell in the current row with an offset of -3 columns wo if your active cell is D3 then RC[-3] points to A3
And yes, evrytime you open the MISSING.... file it takes time and you think you have all the rows to look at 1048576, well that's a lot.
The code as it is is not good, but without really understanding what you want to do and why the fill of the entire P column, sorry it's all unclear.![]()
Well , Other cells can display "NOT INDICATED" but if both Cells(rownum, 16) and Cells(rownum, 17) are #N/A , it still shows #N/A and then the error message will pop up.
Thanks I will read up all the resources that you have given me . I really need it .
Last edited by fluffyvampirekitten; 07-07-2015 at 03:11 AM.
Yeah , it was really alot of records.
Thats why i thought of using the macro to automate the steps as it quite tedious to do it manually.
Anyway, thank you for helping me . It took me days to do this as I have never write macro before and I just started learning excel vba.
There is a function ISNA to trap for these errors.
Of course there are mny sites to help.
This one is ok http://www.excel-easy.com/
This one I frequently visit to look at solutions and samples, most macros work also for 2013
http://www.cpearson.com/Excel/Topic.aspx
If you need help just post it
Happy coding![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks