mardi 14 janvier 2020

IF Then Else if for entire column

I inherited a task at work that someone else setup who is no longer here, there are some macros that have to be run against a spreadsheet with about 17500 rows of data. i need to solve a problem using a macro so that it can be done easily by other people.
i need to try and do an If then Elseif statement against an entire column of data. i wasn't able to figure out the VB code for this, but i DID figure out a spreadsheet formula to do it in one of the sheets...=IF(K2=2,"New York", IF(K2=14,"OEB","NO DISTRICT")). our user data is organized by district codes versus location, so we are adding the location to the data and then bringing the user data into another system.
can this be done in a macro? The user data will change over time, can this be done in a way that if the # of rows increases over time it automatically accounts for the new data? in other words i dont want to define a static range because it will change...

My workaround is fine, however, when the next macro is run to copy the data from one sheet to another, it copies the formulas and not the values. the code in the macro for the copy/paste ids as follows: Set sourceColumn = Workbooks("ZapskyDistrict.xlsm").Worksheets(1).Columns("CT") Set targetColumn = Workbooks("PieReport.xlsx").Worksheets(1).Columns("T") sourceColumn.Copy Destination:=targetColumn

is there a way to do this pasting just the VALUES of CT into the target column?

Aucun commentaire:

Enregistrer un commentaire