Excel Data Import with custom formating rules

%3CLINGO-SUB%20id%3D%22lingo-sub-2337501%22%20slang%3D%22en-US%22%3EExcel%20Data%20Import%20with%20custom%20formating%20rules%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2337501%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20i%20want%20to%20copy-paste%20data%20from%20one%20workbook%20in%20to%20another%20work%20book%20based%20on%20specific%20custom%20cells%20range%20and%20then%20paste%20in%20to%20another%20sheet%20to%20push%20to%20database%20and%20for%20internal%20record.%20The%20problem%20is%20data%20is%20in%20different%20formats%20for%20example%20in%20workbook%201%20Words%20such%20as%20%22Decrease%22%20to%20be%20pasted%20as%20just%20%22D%22%20in%20target%20workbook%2C%20and%20%22Invalid%20Card%22%20to%20be%20pasted%20as%20Digit%20%225%22%20and%20Word%20%22Other%22%20as%206%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22nidospartan_0-1620454373932.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F279272iAC16D58FCC942B8A%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22nidospartan_0-1620454373932.png%22%20alt%3D%22nidospartan_0-1620454373932.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EFor%20example%20the%20data%20in%20above%20sheet%20is%20coming%20via%20a%20web%20form%20filled%20by%20a%20shop%20owned%20and%20then%20want%20to%20save%20it%20via%20a%20macro%20import%20in%20the%20workbook%20below%20without%20manual%20selecting%20each%20cell%3C%2FP%3E%3CP%3EPlease%20help%20any%20help%20is%20appreciated.%3C%2FP%3E%3COL%3E%3CLI%3EIs%20it%20possible%20to%20select%20only%20specific%20cells%20to%20copy%20%3F%3C%2FLI%3E%3CLI%3EIs%20it%20possible%20to%20Change%20formats%20for%20Text%20in%20to%20abbreviated%20or%20short%20Text%20%3F%3C%2FLI%3E%3CLI%3EIs%20it%20possible%20to%20set%20rules%20on%20empty%20cells%20for%20data%20validation%20to%20assign%20values%20to%20text%20strings%3F%3C%2FLI%3E%3CLI%3EIs%20it%20possible%20to%20set%20data%20validation%20rules%20for%20empty%20or%20blank%20cells%20with%20custom%20Text%20fill%20options%20such%20as%20based%20on%20text%20intent%20%3F%3C%2FLI%3E%3C%2FOL%3E%3CP%3EAny%20help%20will%20be%20highly%20appreciated%2C%20thanks%20in%20advance.%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F156456%22%20target%3D%22_blank%22%3E%40Faraz%20Shaikh%3C%2FA%3Eany%20ideas%20%3F%20please%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2337501%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20Scripts%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2356698%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Data%20Import%20with%20custom%20formating%20rules%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2356698%22%20slang%3D%22en-US%22%3Eall%20the%20questions%20in%20your%20post%20is%20yes%2C%20share%20your%20sample%20workbook%20so%20we%20can%20show%20the%20solution%20in%20your%20sample%20workbook%20and%20you%20can%20implement%20it%20on%20your%20actual%20workbook%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2360055%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Data%20Import%20with%20custom%20formating%20rules%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2360055%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1047584%22%20target%3D%22_blank%22%3E%40Yea_So%3C%2FA%3EHello%20Below%20is%20the%20attached%20workbook%2C%20so%20i%20want%20to%20import%20data%20FROM%20sheet2%26nbsp%3B%20in%20to%20Sheet1%20using%20some%20recorded%20Macro%20to%20automate%20the%20manual%20copy-paste%20and%20typing%20abbreviations%20such%20as%20%22D%22%20for%20Decrease%20and%20%221%22%20for%20True%20and%20%220%22%20for%20False.%20Thanks%20in%20advance%20for%20any%20help%20or%20ideas%20or%20suggestions%20given%20in%20this%20regard%20.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2360366%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Data%20Import%20with%20custom%20formating%20rules%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2360366%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1047925%22%20target%3D%22_blank%22%3E%40nidospartan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHere%20is%20the%20edits%20I%20did%20to%20your%20workbook%3A%3C%2FP%3E%3CP%3EYour%20sample%20data%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Yea_So_0-1621244734730.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F281027iE080CC39DBB4050A%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Yea_So_0-1621244734730.png%22%20alt%3D%22Yea_So_0-1621244734730.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EConverted%20data%20using%20excel%20formulas%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Yea_So_1-1621244785672.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F281028iC7DDE49BF5D738D7%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Yea_So_1-1621244785672.png%22%20alt%3D%22Yea_So_1-1621244785672.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EData%20moved%20Destination%20Form%20using%20UNIQUE%20Funtion%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Yea_So_2-1621244868608.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F281029i09D72D8D3E8B0BAF%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Yea_So_2-1621244868608.png%22%20alt%3D%22Yea_So_2-1621244868608.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EAll%20you%20have%20to%20do%20is%20copy%20and%20paste%20to%20the%20Source%20Data%20Sheet%2C%20and%20it%20will%20automatically%20convert%20the%20data%20based%20on%20the%20Look%20up%20Sheet%20which%20you%20can%20edit%2Fadd%20they're%20dynamic%20tables%20so%20the%20range%20will%20autoadjust%20when%20you%20add%20items%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Yea_So_3-1621245659122.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F281033iDF1FF5E5C06CD395%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Yea_So_3-1621245659122.png%22%20alt%3D%22Yea_So_3-1621245659122.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ELet%20me%20know%20if%20you%20have%20any%20questions%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2360671%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Data%20Import%20with%20custom%20formating%20rules%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2360671%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1047584%22%20target%3D%22_blank%22%3E%40Yea_So%3C%2FA%3E%26nbsp%3B%20Thank%20you%20big%20time%20for%20the%20help%2C%20but%20issue%20is%20the%20data%20in%20source%20sheet%20comes%20from%20a%20web%20form%20and%20then%20it%20is%20copy%20pasted%20for%20few%20columns%20every%20time%20a%20form%20arrives.%20Then%20manually%20typed%20based%20on%20values%20in%20Source%20Sheet%20and%20converted%20to%20Match%20the%20validation%20rules%20in%20Destination%20sheet%20to%20further%20push%20in%20to%20sql%20db.%20So%20i%20want%20to%20set%20rules%20as%20Validation%20to%20create%20a%20sort%20of%20empty%20template%20out%20of%20destination%20sheet.%3C%2FP%3E%3CP%3ESo%20that%20every%20time%20a%20form%20arrives%20with%20a%20click%20of%20macro%20import%20data%20gets%20pasted%20on%20empty%20cells%20based%20on%20set%20validation%20rules%20and%20then%20pushed%20to%20next%20system%20and%20saved%20also%20as%20a%20copy%20for%20the%20record%20in%20another%20excel%20sheet.%3C%2FP%3E%3CP%3EI%20guess%20the%20best%20is%20to%20use%20some%20kind%20of%20RPA%20flow%20from%20inside%20excel%20destination%20sheet%20to%20copy%20only%20selected%20column%20fields%20and%20then%20translate%20them%20based%20on%20validation%20rules%20so%20that%20no%20incorrect%20values%20can%20be%20inserted%20in%20to%20destination%20sheet%20then%20eventually%20in%20to%20database%20server.%3C%2FP%3E%3CP%3ELast%20thing%2C%20how%20can%20i%20replace%20%22N%2FA%22%20with%200%20%3F%20or%20empty%20%3F%20to%20insert%20as%20%22null%22%20value%20in%20db%20%3F%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22nidospartan_0-1621253895457.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F281052iEBC72CB4270C11E9%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22nidospartan_0-1621253895457.png%22%20alt%3D%22nidospartan_0-1621253895457.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2360703%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Data%20Import%20with%20custom%20formating%20rules%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2360703%22%20slang%3D%22en-US%22%3Ein%20the%20Conversion%20Sheet%20Wallet%20column%2C%20change%20the%20formula%20from%3A%3CBR%20%2F%3E%3DIFERROR(VLOOKUP(%24A2%2CSourceData!%24A%241%3A%24N%2424%2C7%2C0)%2C%22N%2FA%22)%3CBR%20%2F%3Eto%3CBR%20%2F%3E%3DIFERROR(VLOOKUP(%24A2%2CSourceData!%24A%241%3A%24N%2424%2C7%2C0)%2C%22%22)%3CBR%20%2F%3Ethen%20copy%20the%20same%20formula%20all%20the%20way%20to%20the%20bottom%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2363113%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Data%20Import%20with%20custom%20formating%20rules%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2363113%22%20slang%3D%22en-US%22%3EThank%20you%20so%20much%20for%20your%20help%20but%20this%20became%20too%20complicated%20for%20me.%20I%20will%20try%20with%20power%20automate%20inside%20excel.%20The%20problem%20i%20am%20facing%20is%20when%20data%20comes%20from%20Web%20form%20in%20an%20excel%20sheet%2C%20i%20am%20unable%20to%20run%20a%20macro%20to%20simple%20copy%20and%20paste%20it%2C%20i%20wish%20excel%20had%20custom%20formatting%20options%20instead%20creating%20another%20sheet%20to%20convert%20as%20that%20simply%20adds%20more%20steps%20and%20more%20work.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2363122%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Data%20Import%20with%20custom%20formating%20rules%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2363122%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1047925%22%20target%3D%22_blank%22%3E%40nidospartan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGood%20luck%20in%20your%20endeavor%20and%20have%20a%20great%20day%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2366285%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Data%20Import%20with%20custom%20formating%20rules%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2366285%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1047925%22%20target%3D%22_blank%22%3E%40nidospartan%3C%2FA%3E%26nbsp%3B%20if%20your%20problem%20is%3A%3C%2FP%3E%3CPRE%3E%3CSPAN%3E%22The%20problem%20i%20am%20facing%20is%20when%20data%20comes%20from%20Web%20form%20in%20an%20excel%20sheet%22%3C%2FSPAN%3E%3C%2FPRE%3E%3CP%3E%3CSPAN%3Efrom%20what%20you%20said%20above%2C%20the%20Web%20form%20is%20an%20excel%20sheet.%20excel%20power%20query%20can%20point%20to%20the%20web%20address%20of%20the%20excel%20sheet%20Web%20form%20and%20display%20it%20into%20your%20local%20excel%20without%20copying%20and%20pasting%2C%20and%20once%20you%20have%20the%20power%20query%20set%20up%20to%20bring%20the%20data%20in%20your%20excel%20you%20can%20either%20use%20macro%20on%20your%20excel%20or%20other%20data%20manipulation%20to%20it.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hello i want to copy-paste data from one workbook in to another work book based on specific custom cells range and then paste in to another sheet to push to database and for internal record. The problem is data is in different formats for example in workbook 1 Words such as "Decrease" to be pasted as just "D" in target workbook, and "Invalid Card" to be pasted as Digit "5" and Word "Other" as 6

nidospartan_0-1620454373932.png

For example the data in above sheet is coming via a web form filled by a shop owned and then want to save it via a macro import in the workbook below without manual selecting each cell

Please help any help is appreciated.

  1. Is it possible to select only specific cells to copy ?
  2. Is it possible to Change formats for Text in to abbreviated or short Text ?
  3. Is it possible to set rules on empty cells for data validation to assign values to text strings?
  4. Is it possible to set data validation rules for empty or blank cells with custom Text fill options such as based on text intent ?

Any help will be highly appreciated, thanks in advance.

@Faraz Shaikhany ideas ? please

8 Replies
all the questions in your post is yes, share your sample workbook so we can show the solution in your sample workbook and you can implement it on your actual workbook

@Yea_SoHello Below is the attached workbook, so i want to import data FROM sheet2  in to Sheet1 using some recorded Macro to automate the manual copy-paste and typing abbreviations such as "D" for Decrease and "1" for True and "0" for False. Thanks in advance for any help or ideas or suggestions given in this regard .

Hi @nidospartan 

Here is the edits I did to your workbook:

Your sample data:

Yea_So_0-1621244734730.png

Converted data using excel formulas:

Yea_So_1-1621244785672.png

Data moved Destination Form using UNIQUE Funtion:

Yea_So_0-1621245910170.png

 

All you have to do is copy and paste to the Source Data Sheet, and it will automatically convert the data based on the Look up Sheet which you can edit/add they're dynamic tables so the range will autoadjust when you add items:

Yea_So_3-1621245659122.png

 

Let me know if you have any questions

@Yea_So  Thank you big time for the help, but issue is the data in source sheet comes from a web form and then it is copy pasted for few columns every time a form arrives. Then manually typed based on values in Source Sheet and converted to Match the validation rules in Destination sheet to further push in to sql db. So i want to set rules as Validation to create a sort of empty template out of destination sheet.

So that every time a form arrives with a click of macro import data gets pasted on empty cells based on set validation rules and then pushed to next system and saved also as a copy for the record in another excel sheet.

I guess the best is to use some kind of RPA flow from inside excel destination sheet to copy only selected column fields and then translate them based on validation rules so that no incorrect values can be inserted in to destination sheet then eventually in to database server.

Last thing, how can i replace "N/A" with 0 ? or empty ? to insert as "null" value in db ?

nidospartan_0-1621253895457.png

 

in the Conversion Sheet Wallet column, change the formula from:
=IFERROR(VLOOKUP($A2,SourceData!$A$1:$N$24,7,0),"N/A")
to
=IFERROR(VLOOKUP($A2,SourceData!$A$1:$N$24,7,0),"")
then copy the same formula all the way to the bottom
Thank you so much for your help but this became too complicated for me. I will try with power automate inside excel. The problem i am facing is when data comes from Web form in an excel sheet, i am unable to run a macro to simple copy and paste it, i wish excel had custom formatting options instead creating another sheet to convert as that simply adds more steps and more work.

Hi @nidospartan 

 

Good luck in your endeavor and have a great day

@nidospartan  if your problem is:

"The problem i am facing is when data comes from Web form in an excel sheet"

from what you said above, the Web form is an excel sheet. excel power query can point to the web address of the excel sheet Web form and display it into your local excel without copying and pasting, and once you have the power query set up to bring the data in your excel you can either use macro on your excel or other data manipulation to it.