Este fórum está sendo desativado

Depois de 9 anos, este fórum será desativado. Mas calma.... estamos migrando para uma comunidade no DISCORD. Junte-se a nós.

ENTRAR PARA DISCORD

Tópicos relacionados a códigos VBA, gravação de macros, etc.
  • Avatar do usuário
Avatar do usuário
Por LeoHenrique
Posts Avatar
#50926
Boa tarde a todos !

Pessoal, estou tentando incluir um "SE" no código abaixo, mas não sei como, pois o mesmo foi adaptado.

É o seguinte, a macro insere a foto na colune G, tendo como base o número correspondente na coluna F. Agora o que preciso é que se na coluna H, que é a coluna de quantidade, estiver zerada ou em branco, que o código não importe a foto.

A B C D E F G H
Código foto foto Quant.
425 xxx 55
850 xxx 42
410 xxx 11
600 xxx 0 > Quant. zerado, não importar foto coluna G
650 xxx > Quant. em branco, não importar foto


'Colocar fotos "fixa" Linha 1 Coluna F
Dim r As Range, sPath As String, shp As Shape
For Each r In Range("F6:F" & Cells(Rows.Count, 2).End(3).Row)
sPath = "S:\Comercial\Usuários\Leandro\Fotos\" & r.Value & ".jpg"
On Error Resume Next
Set shp = ActiveSheet.Shapes.AddPicture(sPath, False, True, _
r.Offset(, 1).Left + r.Offset(, 1).Width * 0.05, _
r.Offset(, 1).Top + r.Offset(, 1).Height * 0.1, _
r.Offset(, 1).Width * 0.9, r.Offset(, 1).Height * 0.8)
On Error GoTo 0
Next r

End Sub


Agradeço quem puder ajudar.

Obrigado,

Leandro Moreira
Por osvaldomp
#50929
Acrescente as duas linhas em vermelho conforme abaixo.

For Each r In Range("F6:F" & Cells(Rows.Count, 2).End(3).Row)
If r.Offset(, 2).Value > 0 Then
...
...
...

End If
Next r
Por osvaldomp
#50932
Olá, Leandro.

Experimente o comando abaixo. Se ainda não funcionar então seria oportuno você disponibilizar uma amostra do seu arquivo Excel.
Código: Selecionar todos
If r.Offset(, 2).Value <> 0 And r.Offset(, 2).Value <> "" Then
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]

Estamos migrando para uma comunidade no Discord