Help me write command in vba(excel) to search and find special cells based on multiple criteria
Hi
My name is Majid Javnmard , I am using Microsoft Office Excel 2010 and I encountered a problem. I sent you a simple example of my excel file that i want to write a command in vba to search and find special cell and copy the row which special cell is in there
somewhere , but the problem is how can i find my special cell with multiple criteria or how can i find my all special cells and copy them somewhere !!?
Let me explain on file that i sent :
This file has 4 headers (X,Y,PerturbNumber,Value), the problem is for example : I want write commnd in vba to copy all rows that each of them has (X=12 and Y=13). how can i ? can you help me ?
My
file : http://s000.tinyupload.com/index.php?file_id=69742844961096241754
Many Thanks
Majid
This worked for me, based on your example:
Sub pMain()
Dim wsSource As Excel.Worksheet
Dim wsDest As Excel.Worksheet
Dim lSource As Long
Dim lDest As Long
Dim lLast As Long
With ThisWorkbook
'Change to suit
Set wsSource = .Worksheets("Sheet1")
Set wsDest = .Worksheets.Add
End With
wsSource.Rows(1).Copy
wsDest.Range("A1").PasteSpecial xlPasteValues
lDest = 2
lLast = wsSource.Cells(wsSource.Rows.Count, "A").End(xlUp).Row
For lSource = 1 To lLast
'Put the conditions below:
If wsSource.Cells(lSource, "A") <> 12 Then GoTo linNext
If wsSource.Cells(lSource, "B") <> 30 Then GoTo linNext
'If wsSource.Cells(lSource, "C") <> "value" Then GoTo linNext
'If wsSource.Cells(lSource, "D") <> "value" Then GoTo linNext
'Conditions were met:
wsSource.Rows(lSource).Copy
wsDest.Rows(lDest).PasteSpecial xlPasteValues
lDest = lDest + 1
linNext:
Next lSource
End Sub
Felipe Costa Gualberto - http://www.ambienteoffice.com.br
Similar Messages
-
When in sleep mode iPhone 4 loses signal but as soon as its on again it searches and finds signal easily but because of this not getting calls or text msges and because it's searching for signal all the time battery not lasting
Here are some observations and a suggestion.
1) I mentioned before, that the number of views of this discussion forum is fast approaching 100,000. I suppose relative to all iPhones sold that is not a great percentage, but 100,000 still sounds pretty impressive to me. Consider also that many people probably have this same Sim problem and are not viewing this discussion forum because thay do not know it exists. How many people are REALLY experiencing this problem? Who knows. But I suspect it is more that 100,000.
2) To the best of my knowledge, Apple does not consult these forums as a guide to awareness of product performance. It may be company policy, but most of the time when I speak to an Apple employee they seem remarkably unaware of the "Top Stories" in the Apple Discussion Forum. This, despite the fact that my personal experience with customer service at Apple is excellent. So, as much as we of this discussion forum are confident SOMEONE important at Apple is reading all our posts and taking them to heart...I am not so sure.
3) I have been told over and over that the best way to gain Apple's attention regarding a problem is to post a comment on their Feedback Site. One comment about a problem is pretty worthless. 100,000 comments on the same issue, I'm guessing, will really get their attention.
4) Some folks have mentioned a recall to address this problem. Although such a thing is always a possibility, I don't see it happening. Why? When the brakes on a Toyota don't work, or that Toyata starts to accelerate without driver intention...well, that involves human life and the stakes are quite high. For many reasons you would see the automotive industry eventually be forced into a recall program under such a situation. But, a phone APPEARS to not nearly be such a life and death device. Or is it? My daughter's iPhone 4S developed a "SIM FAILURE" on the same day her car broke down in the middle of the very rural area we live at around 10:00 pm. She is 17 years old and was coming home from high school play practice. You can imagine the anxiety I and her mother felt when she did not arrive home on time. She eventually walked about a quarter mile to a house of a stranger and had to ask to use their phone to call us. Now, I am not saying that strangers where I live are not to be trusted. But, in addition to being worried out of my mind, I was not happy that an inoperative iPhone 4S caused my daughter to be put in this situation. My biggest concern now is...when will my daughter's iPhone become inoperative again due to SIM FAILURE?
5) The more folks in this discussion forum who post a comment about this issue in Apple's feedback site the more pressing this issue is going to be perceived by Apple. So, I like others, encourage all of you to do so. If this seems like a lot of effort, I offer you these few sentences below that you could just copy and paste into the feedback site.
The link to feedback site is: http://www.apple.com/feedback/
Feel free to use copy/amend/whatever the following as you wish:
Dear Apple,
I wish to register a strong concern about my iPhone's unpredictable inoperability due to failures somehow associated with it's SIM technology. For me, I do not consider this just a significant lack of convenience, but a significant safety issue. Should I need my phone in an emergency situation where it is experiencing a SIM FAILURE, I believe the iPhone will have put me at risk. I would ask you to please give fixing this problem your greatest priority and effort.
Sincerely, XXXX -
How Do I Open The Excel Spreadshee​t And Modify The Cell Data
How can I change the cell content in specific excel spreadsheet with ActiveX control? I am using LabVIEW7.1
you can open the excel file using Active X . The procedur to open the excel file, will get in the examples. There is an ready made Vi. for that.
Then select the properties Cell in active X, and you can change the cell data by doing some modification in that vi. i hope it will help you. -
Save as PDF file as excel file or text file in vba excel
Hi all,
I am opening a PDF document fromm VBA excel. After opening document it should save the document as excel file or text file in one folder.
I am trying to do this with some code but not able to , pls help me thatnks.
Dim AcroApp As Acrobat.CAcroApp
Dim Part1Document As Acrobat.CAcroPDDoc
Set Part1Document = CreateObject("AcroExch.PDDoc")
Part1Document.Open ("Z:\EG MI Information\MIS\Requests\Req_156\NO.1.pdf")
Dim app As Object, avdoc As Object, pageview As Object
Set app = CreateObject("AcroExch.App")
Set avdoc = app.GetActiveDoc
app.MenuItemExecute ("SaveAs")
thanks
AbhijeetHi,
In the documentation for the saveAs function it has the following params
cPath The device-independent path in which to save the file.
cConvID (optional, Acrobat 6.0) A conversion ID string that specifies the conversion
file type.
cFS (optional, Acrobat 7.0) A string that specifies the source file system name.
bCopy (optional, Acrobat 7.0) A Boolean value which, if true, saves the PDF file
as a copy. The default is false.
bPromptToOverwrite (optional, Acrobat 7.0) A Boolean value which, if true, prompts the user if
the destination file already exists. The default is false.
In order to get a text file saved you need to specify the correct cConvID.
See the documentation for the valid convID's - http://livedocs.adobe.com/acrobat_sdk/10/Acrobat10_HTMLHelp/JS_API_AcroJS.88.519.html
Please note the Acrobat SDK contains all the information and does not require much installing ( as it is a zip file(on windows) and a disc image (on Mac) it just needs extracted)
Regards
Malcolm -
How to generate passwordDigest and nonce in VBA excel ?
Hi All,
I need to consumme a webservice in VBA Excel. I need to generate a passwordDigest in order to fill this XML:
<SOAP-ENV:Header>X-WSSE: UsernameToken Username="MYUSERNAME", PasswordDigest="???PasswordDigest???", Nonce="???Nonce???", Created="2015-01-15T20:19:45Z"</SOAP-ENV:Header>
How can I generate a passwordDigest and Nonce in VBA EXcel in order to consume the webservices ?
Thank you for your help,
best regardsHi,
This is the forum to discuss questions and feedback for Microsoft Office, your issue need some VBA DEV, I'll move your question to the MSDN forum for Visual Basic for Applications
http://social.msdn.microsoft.com/Forums/en-US/home?forum=isvvba
The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
George Zhao
TechNet Community Support
It's recommended to download and install
Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
programs. -
BPM process archiving "Processing of archiving write command failed"
Can someone help me with the following problem. After archiving a BPM proces, I get the following messages (summary):
ERROR Processing of archiving write command failed
ERROR Job "d5e2a9d9ea8111e081260000124596b3" could not be run as user"E61006".
LOG -> Processing of archiving write command failed
[EXCEPTION] com.sap.glx.arch.xml.XmlArchException: Cannot create archivable items from object
Caused by: java.lang.ClassCastException: ...
Configuration
I've completed the following steps based on a blog item.
1. created an archive user with the corresponding roles
2. updated the destination DASdefault with the created user -> destination ping = OK
3. created an archive store BPM_ARCH based on unix root folder
4. created home path synchornization with home path /<sisid>/bpm_proc/ and archive store BPM_ARCH
5. start process archiving from manage processes view.
Process Archiving
Manage Process -> Select a process from the table -> Archive button -> Start archiving by using the default settings.
Archiving Monitor
The following log is created which describe that the write command failed.
Write phase log:
[2011.09.29 12:00:18 CEST] INFO Job bpm_proc_write (ID: d5e2a9d9ea8111e081260000124596b3, JMS ID: ID:124596B30000009D-000000000C08) started on Thu, 29 Sep 2011 12:00:18:133 CEST by scheduler: 5e11a5e0df3111decc2d00237d240438
[2011.09.29 12:00:18 CEST] INFO Start execution of job named: bpm_proc_write
[2011.09.29 12:00:18 CEST] INFO Job status: RUNNING
[2011.09.29 12:00:18 CEST] ERROR Processing of archiving write command failed
[2011.09.29 12:00:18 CEST] INFO Start processing of archiving write command ...
Verify Indexes ...
Archive XML schema ...
Resident Policy for object selection is instanceIds = [9ca38cb2343511e0849600269e82721e] , timePeriod = 1317290418551 , inError = false ,
[2011.09.29 12:00:18 CEST] ERROR Job "d5e2a9d9ea8111e081260000124596b3" could not be run as user"E61006".
[2011.09.29 12:00:18 CEST] INFO Job bpm_proc_write (ID: d5e2a9d9ea8111e081260000124596b3, JMS ID: ID:124596B30000009D-000000000C08) ended on Thu, 29 Sep 2011 12:00:18:984 CEST
Log viewer
The following message is created in the log viewer.
Processing of archiving write command failed
[EXCEPTION]
com.sap.glx.arch.xml.XmlArchException: Cannot create archivable items from object
at com.sap.engine.core.thread.execution.CentralExecutor$SingleThread.run(CentralExecutor.java:328)
Caused by: java.lang.ClassCastException: class com.sap.glx.arch.Archivable:sap.com/tcbpemarchear @[email protected]2@alive incompatible with interface com.sap.glx.util.id.UID:library:tcbpembaselib @[email protected]f@alive
at com.sap.glx.arch.him.xml.JaxbTaskExtension.createJaxbObjects(JaxbTaskExtension.java:69)
at com.sap.glx.arch.xml.JaxbSession.fillFromExtensions(JaxbSession.java:73)
at com.sap.glx.arch.pm.xml.ArchProcessExtension.fillHimObjects(ArchProcessExtension.java:113)
at com.sap.glx.arch.pm.xml.ArchProcessExtension.createArchObjectItem(ArchProcessExtension.java:60)
at com.sap.glx.arch.xml.JaxbSession.createArchObjectItems(JaxbSession.java:39)
at com.sap.glx.arch.xml.Marshaller.createItems(Marshaller.java:29)
... 61 moreHi Martin,
I don't have a specific answer sorry, however I do recall seeing a number of OSS notes around BPM archiving whilst searching for a different issue last year - have you checked on there for anything relevant to your currnet version and SP level? There were quite a few notes if memory serves me well!
Regards,
Gareth. -
Write command could not be executed
Hello,
I'm back again with a new error that I can't seem to figure
out. Any help would be greatly appreciated.
Error Occurred While Processing Request
Error: WRITE command could not be executed
write
E:\Websites\thriftypockets\wwwroot\coupon\photos\generated\105436.gif
The error occurred in
E:\Websites\thriftypockets.com\wwwroot\coupon\admin\cpncreate.cfm:
line 293
Called from
E:\Websites\thriftypockets.com\wwwroot\coupon\admin\cpncreate.cfm:
line 290
Called from
E:\Websites\thriftypockets.com\wwwroot\coupon\admin\cpncreate.cfm:
line 34
Called from
E:\Websites\thriftypockets.com\wwwroot\coupon\admin\cpncreate.cfm:
line 1
Called from
E:\Websites\thriftypockets.com\wwwroot\coupon\admin\coupon_preview.cfm:
line 26
Called from
E:\Websites\thriftypockets.com\wwwroot\coupon\admin\coupon.cfm:
line 767
Called from
E:\Websites\thriftypockets.com\wwwroot\coupon\admin\coupon.cfm:
line 1
291 : <cfx_image action="IML"
292 : file="NEW"
293 : x="590"
294 : y="239"
295 : commands="
Thanks in advanceThere are guesses, but I would check:
1. Does the target directory exist?
2. Does the CF application server account does not have
rights to access directory? -
How to write data/result in excel or external data source in c#??
Hello Team,
I have automation framework in c#. So there are multiple testmethod and testclasses.....so i havt to write result of every testmethod ...in below format..in excel
[TestMethod]
public void Demo()
WriteIntoExcel("TestClassName","TestmethodName", Pass/Fail, Time);
I can all info in every methods but i dont know how to write it in excel or any other external datasource after every method .....
Actually i want c# code to which will write data/result in excel ...excel might be saved in shared drive...
Thanks in advanceHi Mon,
We also could use OleDbConnection to insert data into excel.
using System.Data.OleDb;
using Excel = Microsoft.Office.Interop.Excel;
using Microsoft.Office.Interop;
//in the method section use as :
string datevariable = "02/02/2010";
string namevariable = "Shyam";
string strConnectionString ="";
string cmd;
string filepath = ""C:\\sample.xls";
strConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+filePath+@";Extended Properties=""Excel 8.0;HDR=Yes;""" ;
OleDbConnection conn =new OleDbConnection (strConnectionString);
try
conn.Open();
catch(Exception e)
Console.WriteLine(e);
try
// Insert into Sheetname
cmd = "Insert into [Sheet1$] ( [Date], [Name]) values ('" +datevariable+ "','" +namevariable+ "');
//Similarly you can update also
OleDbCommand cmdUpd=new OleDbCommand(cmd);
cmdUpd.Connection = conn;
cmdUpd.ExecuteNonQuery();
conn.Close();
catch(Exception e)
Console.WriteLine(e);
Best regards,
Kristin
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
WRITE command gives unexpected value when currency is JPY (japanse yen)
Hi All
I am getting unexpected value for below WRITE command but only when the currency is JPY (Japan Yen)
lv_amount = 1215.40
lv_currency = u2018JPYu2019.
write lv_amount to ev_amount_ext left-justified no-gap NO-GROUPING currency lv_currency.
Value wrongly gets as ev_amount_ext = 121540 (Decimal takes as full value)
Appreciate your help if you have any idea on this please
Many Thanks
IverHi,
use like this
lv_amount = '1215.40'
lv_currency = u2018JPYu2019.
write lv_amount to ev_amount_ext left-justified no-gap NO-GROUPING currency lv_currency.
other wise.
data lv_amounts type string.
move lv_amount to lv_amounts.
lv_currency = u2018JPYu2019.
write lv_amount to ev_amount_ext left-justified no-gap NO-GROUPING currency lv_currency. -
Error message after write command
Hi,
i have a program that will display an error message after a write command...
it goes like this: when you click on the button change material it will go to the transaction MM02 and when you saved your changes the value of the table will refresh but when it was refresh and there is no data that would retrieve an error message will pop-up no data selected..but when you click on the check button or enter the previous data still appears which is wrong it should go back to the selection screen...
can anybody can help me with this?
thank you...
regards,
maehi,
i am currently in the output table with a valid data and when i change the procurement type from E to F at the button change material(transaction MM02) it should display an error message after saving the changes and then go bak to the selection screen not on the previouse output table...
how will i do it?
thank you -
how i can use write in
event AT SELECTION-SCREEN.Hi,
We can not use the WRITE command in this Event
The event AT SELECTION-SCREEN is the basic form of a whole series of events that occur while the selection screen is being processed.
The standard selection screen in an executable program or in the logical database linked to it is automatically called between the INITIALIZATION and START-OF-SELECTION events. When you call the selection screen, and when users interact with it, the ABAP runtime environment generates selection screen events, which occur between INITIALIZATION and START-OF-SELECTION.
You can define event blocks for these events in your program to change the selection screen or process user input.
You can use the COMMENT to write the text in the selection screen ..
To place comments on the selection screen, you use:
SELECTION-SCREEN COMMENT [/]pos(len) comm [FOR FIELD f]
[MODIF ID key].
This statement writes the comm comment on the selection screen. For comm, you can specify a text symbol or a field name with a maximum length of eight characters. This character field must not be declared with the DATA statement, but is generated automatically with length len. The field must be filled before the selection screen is called. You must always specify the pos(len) addition. Only if there are several elements in one line can you omit pos.
The text comm will be displayed, starting in column pos, for a length of len. If you do not use a slash (/), the comment is written into the current line; otherwise a new line is created.
You use FOR FIELD f to assign a field label to the comment. f can be the name of a parameter or a selection criterion. As a result, if the user requests help on the comment on the selection screen, the help text for the assigned field f is displayed.
The MODIF ID keyaddition has the same function as for the PARAMETERS statement. You can use it to modify the comment before the selection screen is called.
Here is the exampel Program
REPORT demo_sel_screen_select_comment.
SELECTION-SCREEN COMMENT /2(50) text-001 MODIF ID sc1.
SELECTION-SCREEN SKIP 2.
SELECTION-SCREEN COMMENT /10(30) comm1.
SELECTION-SCREEN ULINE.
PARAMETERS: r1 RADIOBUTTON GROUP rad1,
r2 RADIOBUTTON GROUP rad1,
r3 RADIOBUTTON GROUP rad1.
SELECTION-SCREEN ULINE /1(50).
SELECTION-SCREEN COMMENT /10(30) comm2.
SELECTION-SCREEN ULINE.
PARAMETERS: s1 RADIOBUTTON GROUP rad2,
s2 RADIOBUTTON GROUP rad2,
s3 RADIOBUTTON GROUP rad2.
SELECTION-SCREEN ULINE /1(50).
INITIALIZATION.
COMM1 ='Radio Button Group 1'.
COMM2 ='Radio Button Group 2'.
LOOP AT SCREEN.
IF screen-group1 = 'SC1'.
screen-intensified = '1'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
Regards
Sudheer -
How to write commands to Crossbow MDA300 with LabVIEW?
I am able to read data from Nodes using LabVIEW, but I would like to write commands to the nodes using LabVIEW. How can I do that? I am using Iris mote, MDA300, MTS420, MTA 310 sensor boards and MIB520 USB board gateway board and I had got LabVIEW drivers when I purchased the kit. Kindly help.
Attachments:
Crossbow WSN .docx 319 KBHello,
I am also using the same components which you have used. but i don't have drivers for it. can you please tell me from where i can get them. -
How to read and write data in to a specified range of cells(it include multiple row & columns) in excel
CVI Comes with a sample project that explains how to read/write to a Excel file: choose "Explore examples..." in CVI welcome page and navigate to <cviSampleDir>\activex\excel folder where you can load excel2000dem.prj.
Proud to use LW/CVI from 3.1 on.
My contributions to the Developer Zone Community
If I have helped you, why not giving me a kudos? -
Hi,
I currently have a load cell that I have interfaced with a RS232 port. The load cell is sending string data which I am collecting using the I/O Instrument Assist manager in LabView. I am collecting that data, converting to dynamic type and writing to a LabView meaurement file. I have this setup in a while loop to keep collecting data. I am also writing string data via another RS232 port to a stepper motor driver. I am currently just doing testing of the driver/motor using the LabView example code Basic_read_and_write.vi. What I basically wish to do is that when the load cell reading reaches a target value, I send a diferrent string to the stepper motor driver. The initial write string to the drive cell is "M+", which makes the motor move forward at constant velocity. The motor will apply a force on the load cell. When this force reaches a target value, I want the write string to the driver to change to "M-", which moves the stepper motor backwards at constant velocity.
I was thinking of using the case structure function and having the "true" case as the move forwatd string and the "false" case as the move backward string. I was then going to use the function in the string palette that outputs a boolean "true" or "false" depending on the value of the input string, where the "true" or "false" output is wired to the case structure.
Does anyone have some better suggestions than what I have thought of? This seams a bit convuluted. Can someone see a modification of the 2 port read/write example. Any help would be really appreciated.
Cheers,
DaveHello Dave,
This sounds like the exact programming logic you should be using. Case structures are the perfect tool for decision making for a continuous process. You basically want to execute different code (write commands) based upon input values from earlier code (read commands). This is exactly what case structures are used for.
Thank you and good luck,
Michael Chaney
Systems Engineer - TestStand
National Instruments -
First, thanks for this resource. I've used this forum quite a bit as a "lurker" and it's gotten me this far. Hoping to learn a bit, so I can contribute
Anyway, my issue is this:
I am ultimately trying to write an 8Mb binary file to an 8Mb Serial Flash device via the Total Phase Aardvark. The writes to the flash device I am using are limited to 256 bytes per write command. The vi program attached is capable of writing 256 bytes at a time, but not anything more. I realize I need to incorporate some sort of "For Loop" (and I understand that I'd want to do it =(File Size)/256 interations, but I can't seem to figure out how.
Does anyone have any quick advice to drive me in the right direction?
Thank you!
Attachments:
Aardvark bin test 02.vi 33 KBWell, you seem to have answered your own question, so it's not clear what your specific issue is. Is it how to extract 256 bytes at a time?
As for the code... umm... I'm not entirely sure what you're trying to accomplish with the whole top half of your code, but it seems to me that almost the whole thing can be replaced by a single call to the Read Binary File function. What is the format of these binary files?
Maybe you are looking for
-
PROBLEM WITH GRAPH DRAWING PACKAGE
Hi all, I have been trying to compile and run some code using "JOPenChart" a free charting tool, but I am having many problems. Here is the small class: import de.progra.charting.*; import de.progra.charting.model.*; import de.progra.charting.render.
-
my fire wire doesnt recognise a camera or a hard disk can i get it repaired or do i need a new card!!??
-
How to handle Events in OO abap.
Hii all as im new to SAP and ABAP , i want to know , what are events all about and how to handle events? Like how to guide double click to call a transaction , or to create a hot sopt and then , calling the transaction........... Please Help.
-
How can I get Firefox to use Front Page 2003 as an editor for my website?
I have a website called www.gethsemanechurch.net. I use Front Page 2003 to update and maintain the site. Currently this was all being done using IE. However, my IE is now updated to IE10 and I am having problems with IE10. I figured I would try to us
-
Elements 10 demo. undocking pictures???
When picture(s) is opened, it is in full window.The picture doesn't separate from the dock. Usually just dragging the tab downwards undocks the picture into a floating window. It makes it unable to view 2 pictures side by side, or drag image elemen