![]() |
Code to Look for Text and then Perform Specified Actions
First, a quick "Thank You!" from myself and others in my department at the
school. I've progressed quite a bit with VBA, and a lot of that is because of those of you who have helped me here. I'm still a novice, though, so I hope I explain this conundrum well: I have set up a gradebook and written a macro in workbook "SG GB S2009". This macro opens up "AccelTest Results.csv", which is updated before the macro runs. This update includes changing previous scores (when students retake quizzes, for example). The macro takes the information from Column B (a quiz title in Row 1, then the individual scores starting in Row 4), then searches "SG GB S2009" for the first unused column, and then pastes that information. The macro then loops, so that in "AccelTest Results", it moves over to Column C, copies, then searches "SG GB S2009" for the next open column, pastes. And then again, until all quizzes have been entered. This is all well and good for a one time run, but I would like to write a code such that when the macro looks in "AccelTest Results" and gets the quiz title and scores, it searches Row 7 in "SG GB S2009" (which has the titles of each assignment" and tries to match the quiz title to an assignment title. If it does, it stops, and pastes the scores over the previous scores, thereby updating the gradebook. If it cannot match a title, it continues as it normally would, looking for the next empty column. The second question: I also cannot figure out how to get the macro to search a specific column or row for a name, then when it finds it, look in another row or cell, a specified distance away, and get or enter information (depending on what I'm doing). I have learned to use the "If... Then... Else..." and "Do While" and "Do While Not" statements, and I think I know how to use "With". But I cannot figure out how to get the macro to look for a specific name. Thanks! |
Code to Look for Text and then Perform Specified Actions
Afraid I can't help with first bit, but for 2nd question.
something like For each cell in Range("C2:C100") If cell.value = "Student Name" then cell.offset(0,7).value = "Value you want entered" 'Offset works where 1st number is rows down (negative to go up), 2nd number is columns right (negative to go left) YourValue = cell.offset(0,4) 'Retrieves a value 4 cells to the left of name end if next cell -- Best Regards, Luke M *Remember to click "yes" if this post helped you!* "SeventhFloorProfessor" wrote: First, a quick "Thank You!" from myself and others in my department at the school. I've progressed quite a bit with VBA, and a lot of that is because of those of you who have helped me here. I'm still a novice, though, so I hope I explain this conundrum well: I have set up a gradebook and written a macro in workbook "SG GB S2009". This macro opens up "AccelTest Results.csv", which is updated before the macro runs. This update includes changing previous scores (when students retake quizzes, for example). The macro takes the information from Column B (a quiz title in Row 1, then the individual scores starting in Row 4), then searches "SG GB S2009" for the first unused column, and then pastes that information. The macro then loops, so that in "AccelTest Results", it moves over to Column C, copies, then searches "SG GB S2009" for the next open column, pastes. And then again, until all quizzes have been entered. This is all well and good for a one time run, but I would like to write a code such that when the macro looks in "AccelTest Results" and gets the quiz title and scores, it searches Row 7 in "SG GB S2009" (which has the titles of each assignment" and tries to match the quiz title to an assignment title. If it does, it stops, and pastes the scores over the previous scores, thereby updating the gradebook. If it cannot match a title, it continues as it normally would, looking for the next empty column. The second question: I also cannot figure out how to get the macro to search a specific column or row for a name, then when it finds it, look in another row or cell, a specified distance away, and get or enter information (depending on what I'm doing). I have learned to use the "If... Then... Else..." and "Do While" and "Do While Not" statements, and I think I know how to use "With". But I cannot figure out how to get the macro to look for a specific name. Thanks! |
All times are GMT +1. The time now is 10:11 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com