SMALL

조건을 만족하지 않는 행을 삭제하는 VBA Code

 

조건 : A행은 11개의 숫자로 이루어져 있는데 조건을 만족하지 않는 행(Row)은 삭제하라




Sub 행삭제()

    Dim Counter
    Dim i, r As Integer
    Dim rngAll As Range        '// 범위 전체 영역 변수

    Application.ScreenUpdating = False        '화면 업데이트 (일시) 정지
    Cells(2, "A").Select    '// 현재 어느셀에 위치하든 A2 셀을 선택하라
    Set rngAll = Range([A2], Cells(Rows.Count, "A").End(3))
    '// 시작행 A2, 마지막행 자동인식
    Counter = rngAll.Rows.Count

    For i = 1 To Counter

        If Len(ActiveCell.Value) <> 11  Or Not IsNumeric(ActiveCell.Value) Then 

            '// 현재 셀의 길이가 11이 아니거나 숫자가 아니면

'// If ActiveCell.Value = 0  Or Not IsNumeric(ActiveCell.Value) Then


            Selection.EntireRow.Delete     '//해당행 전체 삭제
            Counter = Counter - 1          '// 행이 삭제되어 전체행 수를 하나 줄임
            r = r + 1         '// 삭제된 행의 수를 카운트
        Else
            ActiveCell.Offset(1, 0).Select    '// 아래행으로 이동
        End If
    Next i
    Msgbox "총" & r & "행 삭제"
End Sub



출처: https://link2me.tistory.com/271 [소소한 일상 및 업무TIP 다루기]

LIST
블로그 이미지

SeoHW

,
SMALL

var json = JSON.parse(JSON.stringify(req.query.p) //json 파라미터 req.query.p

 

var jp= eval("(" + req.query.p + ")") //파라미터로 받은 josn "{a: '22'}" 이런식으로 ""가 붙어있으므로 제거를위해 eval을 해준다  "{a: '22'}" -> {a: '22'} 이렇게된다

 

db.collection("컬렉션이름").updateMany({조건}, { $set : jp } , false , true ) 

.then(result =>{

         res.json({ result: 'ok' })

})

 

결과

 

a:22 

 

필드추가된걸확인할수있다.

LIST

'mongoDB' 카테고리의 다른 글

Mongo DB 쿼리 옵션 목록  (0) 2021.10.27
블로그 이미지

SeoHW

,
SMALL

테이블로 디자인된 화면에 동적으로 내용이 변경되는 경우

텍스트의 크기에 따라 테이블이 변경되어 디자인이 깨질 경우가 있다.

다음과 같이 td 태그에  <td width=50 style="word-break:break-all"> 스타일을 지정하여 위와 같은 문제를 해결 할 수 있다.

 

1. html의 경우

- 사이즈를 지정하고 스타일을 정해준다.

// 방법 1 

<table border=1 width=100>
 <tr><td style="word-break:break-all">dddd</td><td>eeee</td></tr>
 <tr><td width=50 style="word-break:break-all" >aaaaaaaaaaaaaaaaaaaddddddddddddddddddddddddddddddddda</td><td width=50>bbbb</td></tr>
 <tr><td>dddd</td><td>eeee</td></tr>
 <tr><td>gggg</td><td>hhhh</td></tr>
</table>

 

 

 //방법2

<table  width="1200" cellpadding="0" cellspacing="1" style="word-wrap:break-word;word-break:break-all;">

 

 

2. javascript 로 동적으로  테이블을 생성할 경우

- 동적으로 테이블 로우를 추가할 경우는 다음과 같이 해준다.

- 사이즈를 지정하고 스타일을 정해준다.

        var newCell_2 = newRow.insertCell(2);
        newCell_2.width = 350;   // td size 지정
        newCell_2.style.wordBreak  = "break-all";

 

 

3. table  자체를 고정할 경우

- 이와 같이 할경우 텍스트 내용이 많을 경우 잘려서 보여지게 된다. 스크롤도 안됨.

<table border=1 width=100 style="table-layout: fixed" >

 

출처:http://blog.daum.net/jooneey22/7006643

LIST
블로그 이미지

SeoHW

,