I need to write a vba macro code in excel
I need to search for word " item" in column A and if found I need to copy data in "C2" and paste from "B3" to until the next word " item" is found and again I need to find next word " item" and copy paste as before in column "B"
I have attached a screen shot of inputs and outputs
Can any one support to write a vba code so it will be helpful for my daily activities..i/p o/p data screen shot
Try:
=IF(E6="","",IF(AND(LEN(E5)>1,LEN(F5)<1),IF(AND(LEN(G6)<1,LEN(F6)<1),"",E5),D5))
or,
=IF(LEN(E5)<1,"",IF(AND(LEN(E4)>1,LEN(F4)<1),IF(AND(LEN(G5)<1,LEN(F5)<1),"",E4),D4))
drag down
This kind of approach solves alot of problems. Let me know if works for you - it should - and if my answer answers your question can you mark the tick box? A Macro would take more time to make. Writing a formula is faster, but one could adapt the formula (its process) into a macro too.
Plus, With the formula hiding/placed in column B you can see the cells updating as you input your data into your sheet.
Related
I'm attempting to design a macro to simplify the update process for my company's order tracking, and I'm struggling with relative references. I'm using Excel 2010.
what I need the macro to do: Find a given part number on one workbook, and use the row number of to update formulas in a a second workbook.
In more detail:
Where |Y|= column letter of original spreadsheet, |X|= row number of original spreadsheet, and |X^|=Row number of ‘All Inventory.xls’
There are 4 separate spreadsheets I would need to run the macro from (It’d be a lot easier if I could have the 4 as separate pages on one spreadsheet, but unfortunately, my boss is 60 and is a bit fuzzy on how excel works.)
The spreadsheet ‘All Inventory.xls’ is not in table form, and I can’t convert it to one. (the guy who runs inventory is very fuzzy on how spreadsheets work, approximately five years from retirement, and about as friendly as a snapping turtle.)
When run from cell |Y||X| in a table:
Copy content of the cell in table column ‘Part #’ in the same row – structured reference [#[Part #]]|X|
Paste content of cell ‘[#[Part #]]|X|’ into Find/Replace
Switch to spreadsheet ‘All Inventory.xls’
Hit ‘find next’ – will land on cell C|X^|
switch back to original spreadsheet
return to original cell |Y||X|
type “=’[All Inventory.xls]Sheet1’!$E$|X^|”
go to cell |Y+1||X|
type “=’[All Inventory.xls]Sheet1’!$G$|X^|”
go to cell [Y][X+1]
End macro
I've tried recording this directly, while using relative references. Excel didn't like that. I'm not sure where to go from here.
I want to insert the content of a cell or a row of cells into a macro to avoid having to update the macro code.
This is so that people at my office can simply update a list in a spreadsheet instead of having to go change the VBA code.
Is it possible to simply ask Excel to insert text from a cell into VBA and use it to execute the macro?
Thank you!
I'm not positive I understand your question, however to read data from a cell you would use
Worksheet(SheetIndex).Cells(x,y).Value
If you want to loop through rows to get the data doing a for loop would be the easiest way around it.
For i to j
'Do Stuff
Next
If you want to loop through all rows in a sheet find the total number of rows by getting number of used cells.
Worksheet(SheetIndex).UsedRange.Rows.Count
Honestly, I would probably have a button to actually trigger the start of this to increase usability. Code should always be written with scalability in mind so why would they need to change the macro code?
first my apologies for being a noob with regard to Excel Formulas - I did search and did not find an answer.
I have a spreadsheet that I am trying to modify. I got two spreadsheets from a client, who gave me a working copy and one that he had modified. There is a #REF error in the modified version. If I look at the working copy the formula looks like this.
=VLOOKUP($C$1,'Client Rates'!$A$2:J$228,5,FALSE)
As you can see it has quote marks in the table_array parameter because it does have a space in it. However I cannot enter it this way as it throws an error every time I try. Error is something like this - 'There is a problem with this formula. Not trying to type a formula? ... '
How can I enter the work sheet as a parameter with spaces in the name into the formula?
Did you try F2 to edit formula directly. Then highlight section of formula you wish to change then select the actual data you want evaluated by the formula?
Excel will create the correct string for the sheet and area reference for you.
The problem is you are trying to copy and paste directly from on workbook to another. Copying ctrl-c and pasting ctrl-v from one workbook to another may not have the desired effect. If you copy first to notepad or some other text editor and then paste from that text editor all works fine.
I am new to Excel macros but have recently tried them out and find them really useful. The problem is my programming knowledge is limited to Matlab so I'm wondering if someone can suggest a macro for the following problem.
I have collected study data and I want to move it all to one Excel spreadsheet. Each sheet has data for on participant, and there are 67 sheets. The sort of macro which would be useful is one which looks in the same five cells (always D36:D40) of 67 sheets and copies it to a specific part of a row in the new sheet (AKx, ALx, AMx, ANx, AOx where x is the next row down, starting from 3, for every sheet data is copied from).
I feel by code being provided for my specific situation it will be easier for me to understand what the code does and thus I can slowly start to learn some macro code.
You don't need a macro for that. You can just include the file name in the cell referencing.
The formula looks like this:
='file:///C:/[path and filename].xlsx'#$'[sheetname]'.G22
The easiest way to accomplish this is to have both sheets open. In your main sheet, type the "=" and ALT-TAB to the other sheet, click on the cell you wish to reference. Hit return. The value from that cell will appear in your main sheet.
So your main file, can point to those 60 some-odd sheets, and whatever cells you want. Any time you update those files, your main sheet will always be up to date.
i habe many entries in excell ( more than 3000 ).
actually their are hyperlink but just like a text. i need to convert them in excel hyperlink but dont know how do to that with thousends of entries. please help.
\\192.162.0.2\public
\\192.162.0.2\public\Big-PC.log
\\192.162.0.2\public\InstantReview-ExperimentalHive.reg
\\192.162.0.2\public\InstantReview.reg
\\192.168.0.2\public\Invitation-BLUB.ir
Just use the formula & drag;
=HYPERLINK(A1, A1)
Edit;
I put =HYPERLINK(B3, B3) in the formula bar and hit enter (to get the colour effects that don't seem to appear otherwise for some reason) then dragged down;
I'll give you a generic answer to these sorts of problems.
start Macro recording
convert the first item (convert your
fisrt text cell to hyperlink)
stop Macro recording
open the recorded macro and copy the
code snippet that does the job
write a function (using the code snippet) that iterates over
all your items and does the job
(If you have further problems with one specific step, then that should be considered as a new question, I guess)