格式化Excel单元格的多个条件

时间:2018-03-10 09:14:16

标签: excel

我需要根据另一个单元格的值将文本写入单元格,例如:

单元格G1的值为空白,H1的值为0%;当H1中的百分比值大于0%时,我需要将“进行中”写入G1单元格,如果值介于1-99%之间,则需要“进行中”,如果值等于100%,则需要完成。

使用=IF(H48<> 0%, "In progress", "To be started", IF(H48= 100%, "Completed"))

进行了一部分

但是当我尝试指定两个条件时:jQuery(function($){ // Set all variables to be used in scope var frame, selections, attachment, attachmentids = [], galleryThumbnail, galleryThumbnailID, metaBox = $('#gallery-meta-box.postbox'), // Your meta box id here addImgLink = metaBox.find('.upload-custom-img'), delImgLink = metaBox.find('.delete-custom-img'), imgContainer = metaBox.find('.custom-img-container'), imgUl = metaBox.find('.gallery-images'), imgIdInput = metaBox.find('.custom-img-id'), imgIdHiddenField = document.querySelector('.custom-img-id'); // Add image from frame addImgLink.on( 'click', function( event ){ event.preventDefault(); // If the media frame already exists, reopen it if ( frame ) { frame.open(); return; } // Create a new media frame frame = wp.media({ title: 'Select Image', button: { text: 'Add Images' }, multiple: true }); // When an image is selected in the media frame frame.on( 'select', function() { // Get media attachments details from the frame state selections = frame.state().get('selection'); selections.map(function(attachment){ attachment = attachment.toJSON(); // Send the attachment URL to our custom image input field imgUl.append( '<li data-attachment-id="media-id-1993'+attachment.id+'" class="gallerylistitem">' + '<img id="'+attachment.id+'" src="'+attachment.url+'" class="gallery-thumbnail" alt="'+attachment.title+'"/>' + '<a class="delete-custom-img" href="#"><span class="dashicons dashicons-no"></span></a>' + '</li>'); // Send the attachment id to our hidden input attachmentids.push(attachment.id); imgIdInput.val(attachmentids); }); }); // Finally, open the modal on click frame.open(); }); $(function() { $(imgUl).sortable(); $(imgUl).disableSelection(); }); // Delete Image from metabox imgContainer.on( 'click', 'a.delete-custom-img', function(event){ event.preventDefault(); // Delete Image galleryThumbnail = $(this).closest('li').find('img'); galleryThumbnail.parent('li').remove(); // Delete input value by id galleryThumbnailID = galleryThumbnail.attr('id'); imgIdHiddenField.value = imgIdHiddenField.value.split(',').filter(x=>x!==galleryThumbnailID).join(','); }); });

我收到了错误

  

“你为这个函数输入了太多的参数”

怎么了?

2 个答案:

答案 0 :(得分:1)

你可以使用

  =IF(ISBLANK(H1),"To be started",IF(H1=0," ",IF(H1<1,"In progress","Completed")))

即使嵌入另一个IF,您也需要IF(测试条件,真实结果,错误结果)。

所以:

=IF(H48<> 0%, "In progress", "To be started", IF(H48= 100%, "Completed"))

测试:H48<> 0%

真实结果:"In progress"

错误结果:"To be started"

而不是嵌入另一个If作为错误结果测试,您在False结果之后添加了一个不存在的附加参数。

IF(H48= 100%, "Completed")

我认为你可能错过了一个条件结果或至少有一些逻辑:

我想你想要:

如果为空,那么&#34;要开始&#34;

如果为0,那么&#34;在此处插入文字&#34;

如果&lt; 1然后&#34;正在进行&#34;

Else&#34;已完成&#34;虽然这可以返回完成文本值,例如在这种情况下你想要另一个If = 1然后&#34;已完成&#34;

所以可能是这样的:

=IF(ISBLANK(H1),"To be started",IF(H1<1,"In progress",IF(H1=1,"Completed","Unknown")))

或者如果您确实希望零测试(根据评论):

=IF(H1=0,"To be started",IF(H1<1,"In progress",IF(H1=1,"Completed","Unknown")))

答案 1 :(得分:0)

尝试,

stringlist

enter image description here