Hi,
I have an application with customers and ever day I generate a report, copy-paste it to Excel and edit certain data in it. This takes me too long, and I want to have some things automated by a macro.
The problem with that is that I don't know how to do something, here's some background info:
I have the zip-code of every customer, since I live in the netherlands, most zipcodes are build up like this: 1000AA. For another report I create, I need to get the first 4 numbers in one field, and the two letters in another. So I have made this macro:
Range("G2:G200".Select
Selection.TextToColumns Destination:=Range("G2:G200", DataType:=xlFixedWidth, _
OtherChar:="4", FieldInfo:=Array(Array(0, 1), Array(4, 1))
It works like a charm, the only problem is that I have foreign customers too. For example a belgium(our neighbours) zipcode is build up of only 4 numbers and the germans have 5 numbers. For these customers my boss wants me to copy the zipcode in front of the city they live in. There's my problem, I don't know how to do that. I have written an IF statement, which looks at the country field and if it is dutch, it splits and if it is not, it doesn't do anything, but this is not enough, and it only worked for one field. Not for the entire column. I don't know how to go to the next row to redo the action (I hope you understand this sentence, I don't know how to make it clear).
It needs to be a macro, because the sheet is deleted and remade again everyday and I want to have it automated as much as possible.
Thanks
I have an application with customers and ever day I generate a report, copy-paste it to Excel and edit certain data in it. This takes me too long, and I want to have some things automated by a macro.
The problem with that is that I don't know how to do something, here's some background info:
I have the zip-code of every customer, since I live in the netherlands, most zipcodes are build up like this: 1000AA. For another report I create, I need to get the first 4 numbers in one field, and the two letters in another. So I have made this macro:
Range("G2:G200".Select
Selection.TextToColumns Destination:=Range("G2:G200", DataType:=xlFixedWidth, _
OtherChar:="4", FieldInfo:=Array(Array(0, 1), Array(4, 1))
It works like a charm, the only problem is that I have foreign customers too. For example a belgium(our neighbours) zipcode is build up of only 4 numbers and the germans have 5 numbers. For these customers my boss wants me to copy the zipcode in front of the city they live in. There's my problem, I don't know how to do that. I have written an IF statement, which looks at the country field and if it is dutch, it splits and if it is not, it doesn't do anything, but this is not enough, and it only worked for one field. Not for the entire column. I don't know how to go to the next row to redo the action (I hope you understand this sentence, I don't know how to make it clear).
It needs to be a macro, because the sheet is deleted and remade again everyday and I want to have it automated as much as possible.
Thanks