Need help with Excel macro

J

jpickering74

I'm new to the whole macro thing (at least when it comes to building one),
and need some help/guidance regarding one that I'm working on for a pet
project of mine. The database that I'm currently working with has about 3500
rows of data with approximately 30 columns. I'm sorting the data by a date
field, then for a particular date, generating new sheets for all unique rows.
I've gotten the sheet creation to work, and I have even gotten the delete
function to work, but not the way I would like to do it. So, here are my two
questions:

1) Is there a way to make the delete function based on a prompted variable?
For example, the field that I want to delete based on is the year field, so I
have 2008, 2009, 2010, 2011 & 2012 in my field. I want to be able to delete
all rows except a particular year, but don’t want to have to have multiple
macros based on the particular year if I don’t have to. Also, as the project
goes forward, subsequent years will be added, while older years will likely
fall out. Is that possible, and if so, how do I do that?

2) I’ve gotten the macro to review my selection data and generate individual
sheets based on the identifier and rename the sheet. However, as the macro
is generating the new sheets and pasting over the data, the data that it is
pasting for me is just the look-up data. Is it possible to have that macro,
as it is generating the new sheets, look up a value in a certain cell and
paste over it a certain range of data from another sheet? For example, the
data range for my new sheet generation is 4 columns in width and I want it to
read the upper most right cell (which would be static for all sheets) and if
it matched one of two values, to copy a range of data OVER the data that it
just pasted in, and if it didn’t match, to copy a second range of data from a
second sheet. (Note: the macro that was used to generate these sheets came
from the Ron de Bruin web page, and I am forever grateful for that page)

I've considered that I may need to have the new sheets generated into a new
workbook, since a select all would likely paste over the database sheets as
well. Any help would be greatly appreciated. Thank you
 
B

Bob Greenblatt

I'm new to the whole macro thing (at least when it comes to building one),
and need some help/guidance regarding one that I'm working on for a pet
project of mine. The database that I'm currently working with has about 3500
rows of data with approximately 30 columns. I'm sorting the data by a date
field, then for a particular date, generating new sheets for all unique rows.
I've gotten the sheet creation to work, and I have even gotten the delete
function to work, but not the way I would like to do it. So, here are my two
questions:

1) Is there a way to make the delete function based on a prompted variable?
For example, the field that I want to delete based on is the year field, so I
have 2008, 2009, 2010, 2011 & 2012 in my field. I want to be able to delete
all rows except a particular year, but don¹t want to have to have multiple
macros based on the particular year if I don¹t have to. Also, as the project
goes forward, subsequent years will be added, while older years will likely
fall out. Is that possible, and if so, how do I do that?

2) I¹ve gotten the macro to review my selection data and generate individual
sheets based on the identifier and rename the sheet. However, as the macro
is generating the new sheets and pasting over the data, the data that it is
pasting for me is just the look-up data. Is it possible to have that macro,
as it is generating the new sheets, look up a value in a certain cell and
paste over it a certain range of data from another sheet? For example, the
data range for my new sheet generation is 4 columns in width and I want it to
read the upper most right cell (which would be static for all sheets) and if
it matched one of two values, to copy a range of data OVER the data that it
just pasted in, and if it didn¹t match, to copy a second range of data from a
second sheet. (Note: the macro that was used to generate these sheets came
from the Ron de Bruin web page, and I am forever grateful for that page)

I've considered that I may need to have the new sheets generated into a new
workbook, since a select all would likely paste over the database sheets as
well. Any help would be greatly appreciated. Thank you
Well, that is a pretty complete explanation. Much better than we usually
get. However, I'm still confused. I assume you are talking VBA, and not XLM.
I'll try to help, but I may need further information.
1.Yes, of course the delete function can be based on a variable. Look into
the msgbox function to get an example of asking for a value. It may be
better, in your case, to simply enter the variable in a cell, and have the
macro get that.
2.Sure, this is possible too, but I don't understand what your problem is.

The short answer is that "anything" is possible by using a macro. It would
help us both if you could approach this one small step at a time. Post a
small section of the code, explain what you want to do and some code you
have to attempt it, and an explanation of what is not working. Then we can
respond with some specifics.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top