nickwilshaw
New Member
- Joined
- Apr 18, 2011
- Messages
- 13
Hi Guys,
I have a macro that allows me to create a file where there is a change in the name of the column and save it with that new name:
Sub FindNextCustomer()
Workbooks("Book1.xlsm").Activate
Sheets("Customers").Activate
Range("A2").Select
b = Range("A2").Value
Do While ActiveCell.Value = b
ActiveCell.Offset(1, 0).Select
Loop
a = ActiveCell.Value
Workbooks.Add.SaveAs Filename:="H:\Accounts\Nick\Loan Guarantees\" & a & ".xls"
End Sub
However, I cannot get this to loop back on itself to go and look for subsequent instances and repeat
I have tried putting If/Else statements within the loop such as
IF ActiveCell.Offset(1, 0).Value = ActiveCell.Value then ActiveCell.Offset(1, 0).Select
Else a = ActiveCell.Value
Workbooks.Add.SaveAs Filename:="H:\Accounts\Nick\Loan Guarantees\" & a & ".xls
But I get the Else without If Error.
Again, any help would be greatly appreciated.
Also, are there any easy-to-understand references on Loops, ranges, Dim (whatever they are!) - I am only an accounts bod and don't have any IT quals so pls be sympathetic!
Ta,
I have a macro that allows me to create a file where there is a change in the name of the column and save it with that new name:
Sub FindNextCustomer()
Workbooks("Book1.xlsm").Activate
Sheets("Customers").Activate
Range("A2").Select
b = Range("A2").Value
Do While ActiveCell.Value = b
ActiveCell.Offset(1, 0).Select
Loop
a = ActiveCell.Value
Workbooks.Add.SaveAs Filename:="H:\Accounts\Nick\Loan Guarantees\" & a & ".xls"
End Sub
However, I cannot get this to loop back on itself to go and look for subsequent instances and repeat
I have tried putting If/Else statements within the loop such as
IF ActiveCell.Offset(1, 0).Value = ActiveCell.Value then ActiveCell.Offset(1, 0).Select
Else a = ActiveCell.Value
Workbooks.Add.SaveAs Filename:="H:\Accounts\Nick\Loan Guarantees\" & a & ".xls
But I get the Else without If Error.
Again, any help would be greatly appreciated.
Also, are there any easy-to-understand references on Loops, ranges, Dim (whatever they are!) - I am only an accounts bod and don't have any IT quals so pls be sympathetic!
Ta,