Help How can I select only certain Cells from an active row

bwachuga

New Member
Joined
Mar 9, 2005
Messages
2

I want my Macro to select the columns E to J from a table. The Active Row is selected by the user from an Excel Table. So far my macro selects a whole line and looks like this..

Sub kontakt_makro1()
Dim Text1 As String
Dim currentRow As Long
Dim c As Excel.Range

'Schliessen einer geöffneten Datei
Close #1
Open "c:\demotext.txt" For Append As #1
For Each c In Selection
Write #1, c.Value
Next
Close #1
End Sub

The Other problem is that my macro writes in a text file and every line is in quotationmarks which I dont know how to get rid of.

the output looks like this....


"Frau Evelyn Göhler"
"Qualitätsmanagement"
"Klingenbergstraße 16"
"32758 Detmold"
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Try this
Code:
Sub kontakt_makro1()
Dim rng As Range
Dim c As Range
Dim FF

'Schliessen einer geöffneten Datei

    Set rng = Range("E" & Selection.Row & ":J" & Selection.Row)
    
    FF = FreeFile
    Open "c:\demotext.txt" For Append As #FF
    
        For Each c In rng.Cells
            Print #FF, c
        Next c
        
    Close #FF
    
End Sub
 
Upvote 0
Omitting blank cells within the selected Range

Thanks Norie for the code below, it worked.

How can I omit the blank cells within the selected Range?

I have tried using the IsEmpty function but it is not working.


Sub kontakt_makro1()
Dim rng As Range
Dim c As Range
Dim FF

'Schliessen einer geöffneten Datei

Set rng = Range("E" & Selection.Row & ":J" & Selection.Row)

FF = FreeFile
Open "c:\demotext.txt" For Append As #FF

For Each c In rng.Cells
Print #FF, c
Next c

Close #FF

End Sub
 
Upvote 0
Perhaps something like this.
Code:
Sub kontakt_makro1()
Dim rng As Range
Dim c As Range
Dim FF

'Schliessen einer geöffneten Datei

    Set rng = Range("E" & Selection.Row & ":J" & Selection.Row)
    
    FF = FreeFile
    
    Open "c:\demotext.txt" For Append As #FF
    
        For Each c In rng.Cells
            If c.Value = "" Then
                Print #FF, c
            End If
        Next c
        
    Close #FF

End Sub
 
Upvote 0

Forum statistics

Threads
1,216,488
Messages
6,130,952
Members
449,608
Latest member
jacobmudombe

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top