I have a Excel sheet with two columns and I need to create new sheets based on the values of the first column.ie
A B
test1 Value21
test1 Values22
test2 Value21
test2 Value32
test3 Values32
IN this case I need to create three sheets namely test1,test2 and test3
Sheet 1 should contain test1 field and its corresponding values.Similarly sheet 2 and 3 should contain corresponding values.
Can anyone help me in writing an Excel Macro for this
I would recommend using a pivot table instead, depending on what you are trying to achieve.. if you need to do the above then I would try and do the below steps, I’ll leave writing the code up to you, I have put a few functions below to help.
I recommend using the macro recording to work out how to do the copy and paste etc.
Here is an example of adding and delete a work sheet:
Here is a sheetexists function that also makes use of the WorkbookIsOpen function shown below it. This can be used to help you see if a sheet you want to create already exists or not.
I would recommend giving the values in range A a name that way you can iterate over them more easily so you can do this sort of thing:
If you cant do that then you will need a function to check column A for a used range. like this one: